Asking advice on best way to perform an interaction with an external webservice
Hi all. I need to implement an interaction with an external web service. The external webservice basically can either provide or accept messages from my zope application. The messages are either produced by my application (and need to be "sent" to the external application via web service) or produced by the external application, and must be processed by mine. I'm asking then for best practice for this sort of interaction. Following what I have read in other threads, I would assume that, for example for sending, I should do something like: - create a queue of objects which needs to be sent, in one transaction; - sent the objects which need to be sent, in another transaction; The problem, of course, is to minimize (if not avoid at all) the chance to have a Conflict with a double sending of the message. In some sense, this is very close to sending an email via an smtp server, therefore, I assume I should at the right products to look for inspirations. Thanks you all for your time. Marco -- Marco Bizzarri http://iliveinpisa.blogspot.com/
Marco Bizzarri wrote at 2008-8-1 14:57 +0200:
I need to implement an interaction with an external web service.
The external webservice basically can either provide or accept messages from my zope application. The messages are either produced by my application (and need to be "sent" to the external application via web service) or produced by the external application, and must be processed by mine.
When your application is the client ("sent"), then you can use any of Python frameworks (e.g. "ZSI", "soaplib") to interface between Python and the webservice (I fear all these frameworks by now support only SOAP 1.1, not the current SOAP 1.2). When your application must act as server, you have several options (all including some webservice framework) * set up an additional (non-Zope) server with the support of the above mentioned frameworks, let it implement the services. If the service needs to access ZODB data, it may be implemented as a ZEO client (this means, that you must use ZEO as storage provider for both your Zope and your service). * implement WebService demarshalling/marshalling in a Zope object. Then, the demarshalling happens when the Zope object is traversed. Traversal also changes the response to perform the demarshalling of the result. This requires some fix of "ZPublisher" (as it stupidly interprets each POST with content-type "text/xml" als an XML-RPC request. * implement an SOAP ZServer The first option is probably the easiest. We have implemented the second option. The following list demonstrates the complexity in terms of lines, words and characters: newdm: wc *.py 189 650 6709 Marshalling.py 10 20 197 Permissions.py 27 71 745 ReprRpc.py 110 393 3727 Response.py 47 128 1286 RpcType.py 161 613 5097 SoapRpc.py 132 517 4593 WsdlRpc.py 208 721 6645 XmlRpc.py 19 46 464 __init__.py 86 322 2667 utils.py 989 3481 32130 total The third option is probably the most difficult one. -- Dieter
Dieter, thanks for your answer. I've to implement a SOAP client, and I wonder how to interact with the external webservice from a transactional point of view: I don't want to call twice the same service because of ZPublisher redoing transactions, and this sort of things. Regards Marco On Sat, Aug 2, 2008 at 9:59 AM, Dieter Maurer <dieter@handshake.de> wrote:
Marco Bizzarri wrote at 2008-8-1 14:57 +0200:
I need to implement an interaction with an external web service.
The external webservice basically can either provide or accept messages from my zope application. The messages are either produced by my application (and need to be "sent" to the external application via web service) or produced by the external application, and must be processed by mine.
When your application is the client ("sent"), then you can use any of Python frameworks (e.g. "ZSI", "soaplib") to interface between Python and the webservice (I fear all these frameworks by now support only SOAP 1.1, not the current SOAP 1.2).
When your application must act as server, you have several options (all including some webservice framework)
* set up an additional (non-Zope) server with the support of the above mentioned frameworks, let it implement the services.
If the service needs to access ZODB data, it may be implemented as a ZEO client (this means, that you must use ZEO as storage provider for both your Zope and your service).
* implement WebService demarshalling/marshalling in a Zope object. Then, the demarshalling happens when the Zope object is traversed. Traversal also changes the response to perform the demarshalling of the result.
This requires some fix of "ZPublisher" (as it stupidly interprets each POST with content-type "text/xml" als an XML-RPC request.
* implement an SOAP ZServer
The first option is probably the easiest.
We have implemented the second option. The following list demonstrates the complexity in terms of lines, words and characters:
newdm: wc *.py 189 650 6709 Marshalling.py 10 20 197 Permissions.py 27 71 745 ReprRpc.py 110 393 3727 Response.py 47 128 1286 RpcType.py 161 613 5097 SoapRpc.py 132 517 4593 WsdlRpc.py 208 721 6645 XmlRpc.py 19 46 464 __init__.py 86 322 2667 utils.py 989 3481 32130 total
The third option is probably the most difficult one.
-- Dieter
-- Marco Bizzarri http://iliveinpisa.blogspot.com/
--On 2. August 2008 10:11:10 +0200 Marco Bizzarri <marco.bizzarri@gmail.com> wrote:
Dieter, thanks for your answer.
I've to implement a SOAP client, and I wonder how to interact with the external webservice from a transactional point of view: I don't want to call twice the same service because of ZPublisher redoing transactions, and this sort of things.
The transaction module or the ZODB provides a post-commit hook. -aj
participants (3)
-
Andreas Jung -
Dieter Maurer -
Marco Bizzarri