Python Manual Benutzerhandbuch

Seite von 124
Using Multiple Gateways
123
called "
ServiceFailure
". All elements will be qualified in the OSE namespace. Inadequate prior
art has been found as to the most appropriate way to make use of the detail element, so it may be nec-
essary to change this in the future if necessary.
Using Multiple Gateways
Because it is possible to attach multiple HTTP server objects to a particular instance of a HTTP dae-
mon object, you aren’t restricted to having only one instance of an RPC gateway. The first conse-
quence of this fact is that for which ever protocol you intend to use, multiple RPC gateways can be
created which map to distinct parts of the URL namespace.
Such RPC gateways can and would generally be associated with different groups of services. It is pos-
sible that some of the RPC gateways might be protected using user authentication. At the same time,
a HTTP file server object or custom HTTP server object might also be attached to the same HTTP dae-
mon.
files = netsvc.FileServer(os.getcwd())
httpd.attach("/download",files)
user = netsvc.RpcGateway("web-services")
httpd.attach("/service",user)
admin = netsvc.RpcGateway("admin-services")
httpd.attach("/admin",admin)
When creating RPC gateways, you also aren’t restricted to them all being for the same protocol. As
long as they are hosted under different parts of the URL namespace, gateways for all three of the RPC
over HTTP protocols currently supported could be provided against the same set of services. In doing
this, as long as your service fits within the lowest common denominator with respect to the limitations
of the XML-RPC and SOAP protocols, you could leave it up to the user as to which protocol they want
to use.
netrpcgw = netsvc.RpcGateway("web-services")
httpd.attach("/netrpc",netrpcgw)
xmlrpcgw = netsvc.xmlrpc.RpcGateway("web-services")
httpd.attach("/xmlrpc",xmlrpcgw)
soapgw = netsvc.soap.RpcGateway("web-services")
httpd.attach("/soap",soapgw)
Using the various features of the HTTP servlet framework, a diverse set of interfaces could be present-
ed through the same HTTP daemon. In general though, it is recommended that a full blown HTTP serv-
er such as Apache still be used for performing as much of the web serving capabilities as possible.
A suitable model may be to use PHP or PSP on your main web server and have it make requests into
the back end application using one of the RPC over HTTP protocols as necessary. This has the benefit