I'm trying to get some complex types to work between a very simple ZSI SOAP server and client. So you know what I'm talking about, I've placed the code at the bottom of this email.
When running the server & client, I get this output on the server: calling the only exported method 'transfer', I get this (wrapped for email)
Traceback (most recent call last): File "./zsi_client.py", line 10, in <module> result = b.transfer(source='src', dest='dst', quantity=amount) File "/usr/lib/python2.5/site-packages/ZSI/client.py", line 64, in __call__ **kw) File "/usr/lib/python2.5/site-packages/ZSI/client.py", line 171, in RPC return self.Receive(replytype, **kw) File "/usr/lib/python2.5/site-packages/ZSI/client.py", line 503, in Receive return _Binding.Receive(self, replytype, **kw) File "/usr/lib/python2.5/site-packages/ZSI/client.py", line 431, in Receive raise FaultException(msg) ZSI.FaultException: Unparseable message <ZSI:ParseFaultDetail> <ZSI:string>'int' object has no attribute 'typecode'</ZSI:string> <ZSI:trace></ZSI:trace> </ZSI:ParseFaultDetail>
There are a few things weird here. First of all, I pass the third parameter using the name 'quantity', but it arrives named 'Amount'. How did that happen? Second, why do I get the parameters in a single dictionary, instead of passed as simply named parameters? And why can't I even return an integer?
I hope someone can help me out here, since I'm completely at a loss how to fix this. To run my code, save the files then start "python zsi_server.py" and then "python zsi_client.py". I've done this using Python 2.5 and ZSI 2.0.
Greetings, Sybren
-v--v--v--v--v--v--v--v--v- complextypes.py -v--v--v--v--v--v--v--v--v- from ZSI import TC
TC.TypeCode.typechecks = False
class Amount(object): def __init__(self, currency, value, fractional_digits): '''Constructor'''
self.currency = currency self.value = value self.fractional_digits = fractional_digits
from ZSI.client import NamedParamBinding as NPBinding import sys
from complextypes import Amount
b = NPBinding(url='http://localhost:8081/', tracefile=sys.stdout) amount = Amount('EUR', 5322, 2) result = b.transfer(source='src', dest='dst', quantity=amount)
print "Result: %s" % result -^--^--^--^--^--^--^--^--^- zsi_client.py -^--^--^--^--^--^--^--^--^-
------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Pywebsvcs-talk mailing list Pywebsvcs-t...@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pywebsvcs-talk Also archived at http://groups.google.com/group/pywebsvcs
On Sun, Oct 14, 2007 at 11:00:10PM +0200, Sybren Stüvel wrote: > Hi folks,
> I'm trying to get some complex types to work between a very simple ZSI > SOAP server and client. So you know what I'm talking about, I've > placed the code at the bottom of this email.
> When running the server & client, I get this output on the server: > calling the only exported method 'transfer', I get this (wrapped for > email)
> Traceback (most recent call last): > File "./zsi_client.py", line 10, in <module> > result = b.transfer(source='src', dest='dst', quantity=amount) > File "/usr/lib/python2.5/site-packages/ZSI/client.py", line 64, in __call__ > **kw) > File "/usr/lib/python2.5/site-packages/ZSI/client.py", line 171, in RPC > return self.Receive(replytype, **kw) > File "/usr/lib/python2.5/site-packages/ZSI/client.py", line 503, in Receive > return _Binding.Receive(self, replytype, **kw) > File "/usr/lib/python2.5/site-packages/ZSI/client.py", line 431, in Receive > raise FaultException(msg) > ZSI.FaultException: Unparseable message > <ZSI:ParseFaultDetail> > <ZSI:string>'int' object has no attribute 'typecode'</ZSI:string> > <ZSI:trace></ZSI:trace> > </ZSI:ParseFaultDetail>
> There are a few things weird here. First of all, I pass the third > parameter using the name 'quantity', but it arrives named 'Amount'. > How did that happen? Second, why do I get the parameters in a single > dictionary, instead of passed as simply named parameters? And why > can't I even return an integer?
> I hope someone can help me out here, since I'm completely at a loss > how to fix this. To run my code, save the files then start "python > zsi_server.py" and then "python zsi_client.py". I've done this using > Python 2.5 and ZSI 2.0.
> Greetings, > Sybren
> -v--v--v--v--v--v--v--v--v- complextypes.py -v--v--v--v--v--v--v--v--v- > from ZSI import TC
> from ZSI.client import NamedParamBinding as NPBinding > import sys
> from complextypes import Amount
> b = NPBinding(url='http://localhost:8081/', tracefile=sys.stdout) > amount = Amount('EUR', 5322, 2) > result = b.transfer(source='src', dest='dst', quantity=amount)
> print "Result: %s" % result > -^--^--^--^--^--^--^--^--^- zsi_client.py -^--^--^--^--^--^--^--^--^-
> ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Pywebsvcs-talk mailing list > Pywebsvcs-t...@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/pywebsvcs-talk > Also archived at http://groups.google.com/group/pywebsvcs
------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Pywebsvcs-talk mailing list Pywebsvcs-t...@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pywebsvcs-talk Also archived at http://groups.google.com/group/pywebsvcs
Looks like you need to change a couple things. I think all of this is covered in the zsi developers guide, although probably not the 3rd point I make. Please provide specific comments if you don't think it adequately or clearly dealt with these issues.
So with "zsi_server.py", unless everything you return has a typecode to describe it you need to use "rpc=True"
Secondly, with "exported.py" the return value needs to be either a list or a dict.
return {'myInt':0}
is probably what you want.
Third, the complextypes. If a typecode's pyclass is used to parse messages, it must have constructors that take only optional arguments.
> Is there nobody who can help me with this more or less trivial > bit of code?
> Greetings, > Sybren
> On Sun, Oct 14, 2007 at 11:00:10PM +0200, Sybren Stüvel wrote: >> Hi folks,
>> I'm trying to get some complex types to work between a very simple >> ZSI >> SOAP server and client. So you know what I'm talking about, I've >> placed the code at the bottom of this email.
>> When running the server & client, I get this output on the server: >> calling the only exported method 'transfer', I get this (wrapped for >> email)
>> Traceback (most recent call last): >> File "./zsi_client.py", line 10, in <module> >> result = b.transfer(source='src', dest='dst', quantity=amount) >> File "/usr/lib/python2.5/site-packages/ZSI/client.py", line 64, >> in __call__ >> **kw) >> File "/usr/lib/python2.5/site-packages/ZSI/client.py", line 171, >> in RPC >> return self.Receive(replytype, **kw) >> File "/usr/lib/python2.5/site-packages/ZSI/client.py", line 503, >> in Receive >> return _Binding.Receive(self, replytype, **kw) >> File "/usr/lib/python2.5/site-packages/ZSI/client.py", line 431, >> in Receive >> raise FaultException(msg) >> ZSI.FaultException: Unparseable message >> <ZSI:ParseFaultDetail> >> <ZSI:string>'int' object has no attribute 'typecode'</ZSI:string> >> <ZSI:trace></ZSI:trace> >> </ZSI:ParseFaultDetail>
>> There are a few things weird here. First of all, I pass the third >> parameter using the name 'quantity', but it arrives named 'Amount'. >> How did that happen? Second, why do I get the parameters in a single >> dictionary, instead of passed as simply named parameters? And why >> can't I even return an integer?
>> I hope someone can help me out here, since I'm completely at a loss >> how to fix this. To run my code, save the files then start "python >> zsi_server.py" and then "python zsi_client.py". I've done this using >> Python 2.5 and ZSI 2.0.
>> from ZSI.client import NamedParamBinding as NPBinding >> import sys
>> from complextypes import Amount
>> b = NPBinding(url='http://localhost:8081/', tracefile=sys.stdout) >> amount = Amount('EUR', 5322, 2) >> result = b.transfer(source='src', dest='dst', quantity=amount)
>> print "Result: %s" % result >> -^--^--^--^--^--^--^--^--^- zsi_client.py -^--^--^--^--^--^--^--^--^-
>> --------------------------------------------------------------------- >> ---- >> This SF.net email is sponsored by: Splunk Inc. >> Still grepping through log files to find problems? Stop. >> Now Search log events and configuration files using AJAX and a >> browser. >> Download your FREE copy of Splunk now >> http://get.splunk.com/ >> _______________________________________________ >> Pywebsvcs-talk mailing list >> Pywebsvcs-t...@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/pywebsvcs-talk >> Also archived at http://groups.google.com/group/pywebsvcs
> ---------------------------------------------------------------------- > --- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a > browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Pywebsvcs-talk mailing list > Pywebsvcs-t...@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/pywebsvcs-talk > Also archived at http://groups.google.com/group/pywebsvcs
------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Pywebsvcs-talk mailing list Pywebsvcs-t...@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pywebsvcs-talk Also archived at http://groups.google.com/group/pywebsvcs
> I think all of this is covered in the zsi developers guide,
You mean guide-zsi-2.0.pdf? It only covers cases concerning WSDL. Since I'm not working from a WSDL file, I didn't read it. If there is information in there that does apply in cases that don't use WSDL, I recommend a change in chapter titles. Perhaps it should be merged with zsi-2.0.pdf.
> So with "zsi_server.py", unless everything you return has a typecode > to describe it you need to use "rpc=True"
Why isn't this described in any of the examples on the website nor in zsi-2.0.pdf? I find the documentation lacking in describing *why* something is done. It just gives examples without much explanation.
> Secondly, with "exported.py" the return value needs to be either a > list or a dict.
This also isn't described. It is done as such, but it isn't explained nor is any attention drawn to the fact that only lists or dicts can be used. And why can Java SOAP services return integers, booleans and strings, but is ZSI limited to lists or dicts?
> Third, the complextypes. If a typecode's pyclass is used to parse > messages, it must have constructors that take only optional > arguments.
There is an example with a constructor that only takes optional argument, but the documentation doesn't actually tell anyone that this is *required*.
The documentation and ZSI software can be really improved if those things are explained in the documentation and tested in the software. For instance, the typecode class could check that the pyclass has a constructor that can be called without arguments, for example by introspection via ClassName.__init__.func_defaults or by simply creating an instance of the class.
------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Pywebsvcs-talk mailing list Pywebsvcs-t...@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pywebsvcs-talk Also archived at http://groups.google.com/group/pywebsvcs