Greetings; brand-new to SOAP, brand-new to the suds library, I hope I use
the correct terms to describe my problem.
Executive summary: I need to send elements with leading underscores in their
names but they are modified/dropped by suds.
1: Why does the code modify element names with leading underscores? e.g.
'__limit' becomes '_limit' (or is it '@_limit')
2: is there a workaround?
I have a service which, in general, is working fine with suds as a client.
The vendor's docs tell me that the message style
is "Document/Literal". So far I'm doing fine just calling the service ]=
RPC-style:
>> client = Client(url, transport)
>>
>> rslt = client.service.getKeys(name='foo')
>>
However, for some of my queries, I need to set/send parameters with names
that have leading underscores. But, I have found
that the appenders deliberately modify these names and do something other
than expected (by myself, at least) with the
values. Thus, they are just dropped.
This example
below is my experiment in injecting raw SOAP with __inject, and it worked
fine:
msg2 = """\
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:ns0="http://www.service-now.com/sys_journal_field"
xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<ns1:Body>
<ns0:getKeys>
<ns0:name>NOYB</ns0:name>
<ns0:__limit>1</ns0:__limit>
</ns0:getKeys>
</ns1:Body>
</SOAP-ENV:Envelope>
"""
But if I send "client.service.getKeys(name='foo', __limit=1)", it hits
this
code:
https://fedorahosted.org/suds/browser/trunk/suds/mx/appender.py#L191
Even more interesting (and what makes me think that it's a logical bug) is
that this is preventing me from using a
message created from the WSDL:
>> getKeysMessage = uut.factory.create('tns:getKeys')
>> print getKeysMessage
(getKeys){
element = None
element_id = None
name = None
sys_created_by = None
sys_created_on = None
value = None
__use_view = None
__encoded_query = None
__limit = None
__first_row = None
__last_row = None
}
File "/usr/lib/python2.6/site-packages/suds/mx/core.py", line 88, in
append
self.appender.append(parent, content)
File "/usr/lib/python2.6/site-packages/suds/mx/appender.py", line 118, in
append
appender.append(parent, content)
File "/usr/lib/python2.6/site-packages/suds/mx/appender.py", line 275, in
append
Appender.append(self, child, cont)
File "/usr/lib/python2.6/site-packages/suds/mx/appender.py", line 200, in
append
self.marshaller.append(parent, content)
File "/usr/lib/python2.6/site-packages/suds/mx/core.py", line 87, in
append
if self.start(content):
File "/usr/lib/python2.6/site-packages/suds/mx/literal.py", line 102, in
start
raise TypeNotFound(content.tag)
TypeNotFound: Type not found: '__use_view'
If I delattr all of the elements with leading underscores, then calling the
method with that object works just fine.
Can anyone explain what's going on? Why is startswith('_') looked for in
the code? What's the workaround?
Thanks!