I'm running into problems using sharepoint soap API. This is my first time working with python, so I could be totally wrong. However, it seems that there is a bug in how SUDS handles attributes when the schema is defined by "any".
Here is the relative part of the schema: <s:element name="GetListItemsResponse"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="GetListItemsResult"> <s:complexType mixed="true"> <s:sequence> <s:any /> </s:sequence> </s:complexType> </s:element> </s:sequence> </s:complexType> </s:element>
And here is the relative part of the response: <GetListResult> <List DocTemplateUrl="" EmailInsertsFolder="" > ....
This fails with: DEBUG:suds.resolver:searching parent (<Any:0x12fed28 />) for (@EmailInsertsFolder) Traceback (most recent call last): File "C:\development\IDEs\eclipse\workspace\cgi\sharepoint2jira\src\synch\sharepoint2jira.py", line 13, in <module> list = client.service.GetList(listName='Issues List') File "C:\development\python\python-suds-0.3.5\suds\client.py", line 240, in __call__ return target.call(*args, **kwargs) File "C:\development\python\python-suds-0.3.5\suds\client.py", line 379, in call return method(*args, **kwargs) File "C:\development\python\python-suds-0.3.5\suds\client.py", line 240, in __call__ return target.call(*args, **kwargs) File "C:\development\python\python-suds-0.3.5\suds\client.py", line 422, in call return client.invoke(args, kwargs) File "C:\development\python\python-suds-0.3.5\suds\client.py", line 480, in invoke result = self.send(msg) File "C:\development\python\python-suds-0.3.5\suds\client.py", line 505, in send result = self.succeeded(binding, reply.message) File "C:\development\python\python-suds-0.3.5\suds\client.py", line 537, in succeeded r, p = binding.get_reply(self.method, reply) File "C:\development\python\python-suds-0.3.5\suds\bindings\binding.py", line 149, in get_reply result = unmarshaller.process(nodes[0], resolved) File "C:\development\python\python-suds-0.3.5\suds\bindings\unmarshaller.py", line 302, in process return UMBase.process(self, content) File "C:\development\python\python-suds-0.3.5\suds\bindings\unmarshaller.py", line 87, in process data, result = self.append(content) File "C:\development\python\python-suds-0.3.5\suds\bindings\unmarshaller.py", line 103, in append self.append_children(content) File "C:\development\python\python-suds-0.3.5\suds\bindings\unmarshaller.py", line 180, in append_children cdata, cval = self.append(cont) File "C:\development\python\python-suds-0.3.5\suds\bindings\unmarshaller.py", line 102, in append self.append_attributes(content) File "C:\development\python\python-suds-0.3.5\suds\bindings\unmarshaller.py", line 156, in append_attributes self.append_attribute(name, value, content) File "C:\development\python\python-suds-0.3.5\suds\bindings\unmarshaller.py", line 389, in append_attribute type = self.resolver.findattr(name) File "C:\development\python\python-suds-0.3.5\suds\resolver.py", line 364, in findattr result, ancestry = self.getchild(name, parent) ValueError: need more than 0 values to unpack
I was able to trace it down to the Any class in sxbasics.py returning self from get_attribute (which fails to unpack into 2 variables?) Changing the return to (None, []) fixes the problem, but I'm not sure if that's the correct fix or I'm just doing something wrong.
Thanks
On Sun, Apr 26, 2009 at 7:54 AM, Steve Chernyak mrrothstein@gmail.com wrote:
I'm running into problems using sharepoint soap API. This is my first time working with python, so I could be totally wrong. However, it seems that there is a bug in how SUDS handles attributes when the schema is defined by "any".
Here is the relative part of the schema: <s:element name="GetListItemsResponse"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="GetListItemsResult"> <s:complexType mixed="true"> <s:sequence> <s:any /> </s:sequence> </s:complexType> </s:element> </s:sequence> </s:complexType> </s:element>
And here is the relative part of the response:
<GetListResult> <List DocTemplateUrl="" EmailInsertsFolder="" > ....
This fails with: DEBUG:suds.resolver:searching parent (<Any:0x12fed28 />) for (@EmailInsertsFolder) Traceback (most recent call last): File "C:\development\IDEs\eclipse\workspace\cgi\sharepoint2jira\src\synch\sharepoint2jira.py", line 13, in <module> list = client.service.GetList(listName='Issues List') File "C:\development\python\python-suds-0.3.5\suds\client.py", line 240, in __call__ return target.call(*args, **kwargs) File "C:\development\python\python-suds-0.3.5\suds\client.py", line 379, in call return method(*args, **kwargs) File "C:\development\python\python-suds-0.3.5\suds\client.py", line 240, in __call__ return target.call(*args, **kwargs) File "C:\development\python\python-suds-0.3.5\suds\client.py", line 422, in call return client.invoke(args, kwargs) File "C:\development\python\python-suds-0.3.5\suds\client.py", line 480, in invoke result = self.send(msg) File "C:\development\python\python-suds-0.3.5\suds\client.py", line 505, in send result = self.succeeded(binding, reply.message) File "C:\development\python\python-suds-0.3.5\suds\client.py", line 537, in succeeded r, p = binding.get_reply(self.method, reply) File "C:\development\python\python-suds-0.3.5\suds\bindings\binding.py", line 149, in get_reply result = unmarshaller.process(nodes[0], resolved) File "C:\development\python\python-suds-0.3.5\suds\bindings\unmarshaller.py", line 302, in process return UMBase.process(self, content) File "C:\development\python\python-suds-0.3.5\suds\bindings\unmarshaller.py", line 87, in process data, result = self.append(content) File "C:\development\python\python-suds-0.3.5\suds\bindings\unmarshaller.py", line 103, in append self.append_children(content) File "C:\development\python\python-suds-0.3.5\suds\bindings\unmarshaller.py", line 180, in append_children cdata, cval = self.append(cont) File "C:\development\python\python-suds-0.3.5\suds\bindings\unmarshaller.py", line 102, in append self.append_attributes(content) File "C:\development\python\python-suds-0.3.5\suds\bindings\unmarshaller.py", line 156, in append_attributes self.append_attribute(name, value, content) File "C:\development\python\python-suds-0.3.5\suds\bindings\unmarshaller.py", line 389, in append_attribute type = self.resolver.findattr(name) File "C:\development\python\python-suds-0.3.5\suds\resolver.py", line 364, in findattr result, ancestry = self.getchild(name, parent) ValueError: need more than 0 values to unpack
I was able to trace it down to the Any class in sxbasics.py returning self from get_attribute (which fails to unpack into 2 variables?) Changing the return to (None, []) fixes the problem, but I'm not sure if that's the correct fix or I'm just doing something wrong.
Looks like it might be fixed in trunk:
https://fedorahosted.org/suds/browser/trunk/suds/xsd/sxbasic.py
If you might end up using some WS-Security features you might want to try my branch which has some WS-Security additions on top of trunk:
http://bitbucket.org/schmichael/suds-timestamp/
Hope that helps!
Michael Schurter
Hi Michael,
I've checked out the latest version, but still get the same error. The change I'm making is in the get_attribute method of Any class. It looks like this in trunk: def get_attribute(self, name): """ Get (find) a I{non-attribute} attribute by name. @param name: A attribute name. @type name: str @return: The requested attribute. @rtype: L{SchemaObject} """ return self
I'm changing it to: def get_attribute(self, name): """ Get (find) a I{non-attribute} attribute by name. @param name: A attribute name. @type name: str @return: The requested (child, ancestry). @rtype: (L{SchemaObject}, [L{SchemaObject},..]) """ return (None, [])
This seems to work. However, I'm not sure if this just ignores the actual problem.
Thanks
Did't reply to all first time.
On Mon, Apr 27, 2009 at 8:14 AM, Steve Chernyak mrrothstein@gmail.com wrote:
Hi Michael,
I've checked out the latest version, but still get the same error. The change I'm making is in the get_attribute method of Any class. It looks like this in trunk: def get_attribute(self, name): """ Get (find) a I{non-attribute} attribute by name. @param name: A attribute name. @type name: str @return: The requested attribute. @rtype: L{SchemaObject} """ return self
I'm changing it to: def get_attribute(self, name): """ Get (find) a I{non-attribute} attribute by name. @param name: A attribute name. @type name: str @return: The requested (child, ancestry). @rtype: (L{SchemaObject}, [L{SchemaObject},..]) """ return (None, [])
This seems to work. However, I'm not sure if this just ignores the actual problem.
Thanks
Did't reply to all first time.
Ah, sorry. I must have been looking at get_child. Perhaps just remove the get_attribute method from the Any class altogether so it uses the get_attribute method on its parent class? (see suds/xsd/sxbase.py:129)
Not sure if thats the right behavior, but it will at least get you the right data type.
Sorry I couldn't be more help.
Steve,
I've been on vaction and just got caught up on this.
Your fix here is very close. The Any object get_child() and get_attribute() are overridden here to match anything and return an Any object which continues to match anything (and so on, and so on ...). Since the caller may interrogate the returned object, I'd rather it was an Any object rather then None just to be on the safe side. I've committed this fix (https://fedorahosted.org/suds/changeset/502) and hope it will meets you needs.
Please let me know if this works for you.
Regards,
Jeff
Steve Chernyak wrote:
Hi Michael,
I've checked out the latest version, but still get the same error. The change I'm making is in the get_attribute method of Any class. It looks like this in trunk: def get_attribute(self, name): """ Get (find) a I{non-attribute} attribute by name. @param name: A attribute name. @type name: str @return: The requested attribute. @rtype: L{SchemaObject} """ return self
I'm changing it to: def get_attribute(self, name): """ Get (find) a I{non-attribute} attribute by name. @param name: A attribute name. @type name: str @return: The requested (child, ancestry). @rtype: (L{SchemaObject}, [L{SchemaObject},..]) """ return (None, [])
This seems to work. However, I'm not sure if this just ignores the actual problem.
Thanks
Did't reply to all first time.
fedora-suds-list mailing list fedora-suds-list@redhat.com https://www.redhat.com/mailman/listinfo/fedora-suds-list