Forcing empty objects to send
by Joshua J. Kugler
Is there a way to force suds to send an empty object?
The Google adwords API requires an empty campaign selector for a "get
everything" call (and an empty statsSelector object in that selector
for "all stats), but if I use the factory to create a selector and set
no values:
(CampaignSelector){
ids[] = <empty>
campaignStatuses[] = <empty>
statsSelector =
(StatsSelector){
dateRange =
(DateRange){
min = None
max = None
}
StatsSelector.Type = None
}
paging =
(Paging){
startIndex = None
numberResults = None
}
}
suds sends
<ns1:Body>
<ns0:get/>
</ns1:Body>
when I pass in this "unmodified" selector.
I would like suds to send something like (not 100% sure of all the
namespaces, etc):
<ns0:get>
<ns0:selector>
<ns0:statsSelector/>
</ns0:selector>
</ns0:get>
Is there any way to do this?
Thanks!
j
--
Joshua Kugler
Part-Time System Admin/Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/ ID 0x73B13B6A
14 years, 1 month
Problem with SOAP response parsing
by Elyrwen Dynesh
Hello,
I encountered a problem with parsing a SOAP response by suds. It seems that
suds cannot parse the whole response and returns to a user only a part of
the response.
In details:
I have a function popTabularResultRows which is supposed to return a list of
results (given by rows):
Input: popTabularResultRows (SOAP:body, use = encoded)
authString [ string ]
requestId [ int ]
maxRows [ int ]
returnValueInfo [ boolean ]
returnValueSid [ boolean ]
returnValueIess [ boolean ]
Output: popTabularResultRowsResponse (SOAP:body, use = encoded)
valueInfo [ TabularResultValueInfo ]
* sid [ nonNegativeInteger ]
* iess [ string ]
rows [ TabularResultRow ]
* ts [ nonNegativeInteger ]
* values (optional, unbounded) [ TabularResultValue ]
o value [ float ]
o valueS64 (optional) [ long ]
o valueU64 (optional) [ unsignedLong ]
o valueDouble (optional) [ double ]
o qual [ byte ]
o tss [ int ]
o sid (optional) [ nonNegativeInteger ]
o iess (optional) [ string ]
o corId (optional) [ nonNegativeInteger ]
rowCount [ int ]
The function is defined in WSDL as follows:
<message name="popTabularResultRows">
<part name="authString" type="xsd:string"/>
<part name="requestId" type="xsd:int"/>
<part name="maxRows" type="xsd:int"/>
<part name="returnValueInfo" type="xsd:boolean"/>
<part name="returnValueSid" type="xsd:boolean"/>
<part name="returnValueIess" type="xsd:boolean"/>
</message>
With dependencies:
<message name="popTabularResultRowsResponse">
<part name="valueInfo" type="eds:TabularResultValueInfo"/>
<part name="rows" type="eds:TabularResultRow"/>
<part name="rowCount" type="xsd:int"/>
</message>
And complex types:
<complexType name="TabularResultRow">
<sequence>
<element name="ts" type="xsd:nonNegativeInteger" minOccurs="1"
maxOccurs="1"/>
<element name="values" type="eds:TabularResultValue" minOccurs="0"
maxOccurs="unbounded" nillable="true"/>
</sequence>
</complexType>
<complexType name="TabularResultValue">
<sequence>
<element name="value" type="xsd:float" minOccurs="1" maxOccurs="1"/>
<element name="valueS64" type="xsd:long" minOccurs="0" maxOccurs="1"
nillable="true"/>
<element name="valueU64" type="xsd:unsignedLong" minOccurs="0" maxOccurs="1"
nillable="true"/>
<element name="valueDouble" type="xsd:double" minOccurs="0" maxOccurs="1"
nillable="true"/>
<element name="qual" type="xsd:byte" minOccurs="1" maxOccurs="1"/>
<element name="tss" type="xsd:int" minOccurs="1" maxOccurs="1"/>
<element name="sid" type="xsd:nonNegativeInteger" minOccurs="0"
maxOccurs="1" nillable="true"/>
<element name="iess" type="xsd:string" minOccurs="0" maxOccurs="1"
nillable="true"/>
<element name="corId" type="xsd:nonNegativeInteger" minOccurs="0"
maxOccurs="1" nillable="true"/>
</sequence>
</complexType>
The problem is that the method popTabularResultRows returns just one item in
rows wherease the XML that arrives has more items:
*XML response (** rows part in italics )**:*
</SOAP-ENV:Envelope>
DEBUG:suds.client:headers = {'SOAPAction': u'""', 'Content-Type':
'text/xml'}
DEBUG:suds.client:http succeeded:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd
="http://www.w3.org/2001/XMLSchema" xmlns:eds="http://www.tt.com.pl/eds.wsdl
">
<SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body SOAP-ENV:encodingStyle="
http://schemas.xmlsoap.org/soap/encoding/"><eds:
popTabularResultRowsResponse><valueInfo><sid>3887</sid><iess>testshade01</iess></valueInfo>
*
<rows><ts>1269425044</ts><values><value>0.000000</value><qual>78</qual><tss>0</tss><iess>testshade01</iess></
values></rows>
<rows><ts>1269428644</ts><values><value>0.000000</value><qual>78</qual><tss>0</tss><iess>testshade01</iess></values></rows><rows><ts>1269432244</ts><values><value>0.000000</value><qual>7
8</qual><tss>0</tss><iess>testshade01</iess></values></rows><rows><ts>1269435844</ts><values><value>0.000000</value><qual>78</qual><tss>0</tss><iess>testshade01</iess></values></rows><rows><ts>1269439
444</ts><values><value>0.000000</value><qual>78</qual><tss>0</tss><iess>testshade01</iess></values></rows><rows><ts>1269443044</ts><values><value>0.000000</value><qual>78</qual><tss>0</tss><iess>tests
hade01</iess></values></rows>*
<rowCount>6</rowCount></eds:popTabularResultRowsResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
*In python when printing the reponse I got (just one row):
*
(reply){
valueInfo =
(TabularResultValueInfo){
sid = 3887
iess = "testshade01"
}
rows =
(TabularResultRow){
ts = 1269443044
values[] =
(TabularResultValue){
value = 0.0
qual = 78
tss = 0
iess = "testshade01"
},
}
rowCount = 6
}
{'ts': [], 'testshade01': []}
What's wrong? Is it a bug?
14 years, 1 month
suds + python-ntlm times out when contacting an SSL web service
by Chris Rose
When I try to connect to an MS CRM web service using suds/python-ntlm, I
am getting a timeout on requests. However, the code that I'm trying to
replace -- which calls out to the cURL command line app to do the same
call -- succeeds.
Here's the code that is making the request, followed by the output. The
cURL command code is below that, and its response follows. Hosts, users,
and passwords have been changed to protect the innocent, of course.
wsdl_url =
'https://client.service.host/MSCrmServices/2007/MetadataService.asmx?WSDL'
username = r'domain\user.name'
password = 'userpass'
from suds.transport.https import WindowsHttpAuthenticated
from suds.client import Client
import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
logging.getLogger('suds.transport').setLevel(logging.DEBUG)
ntlmTransport = WindowsHttpAuthenticated(username=username,
password=password)
metadata_client = Client(wsdl_url, transport=ntlmTransport)
request = metadata_client.factory.create('RetrieveAttributeRequest')
request.MetadataId = '00000000-0000-0000-0000-000000000000'
request.EntityLogicalName = 'opportunity'
request.LogicalName = 'new_typeofcontact'
request.RetrieveAsIfPublished = 'false'
attr = metadata_client.service.Execute(request)
print attr
Here's the output:
DEBUG:suds.client:sending to
(http://client.service.host/MSCrmServices/2007/MetadataService.asmx)
message:
<SOAP-ENV:Envelope
xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://schemas.microsoft.com/crm/2007/WebServices"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<ns0:Body>
<ns1:Execute>
<ns1:Request xsi:type="ns1:RetrieveAttributeRequest">
<ns1:MetadataId>00000000-0000-0000-0000-000000000000</ns1:MetadataId>
<ns1:EntityLogicalName>opportunity</ns1:EntityLogicalName>
<ns1:LogicalName>new_typeofcontact</ns1:LogicalName>
<ns1:RetrieveAsIfPublished>false</ns1:RetrieveAsIfPublished>
</ns1:Request>
</ns1:Execute>
</ns0:Body>
</SOAP-ENV:Envelope>
DEBUG:suds.client:headers = {'SOAPAction':
u'"http://schemas.microsoft.com/crm/2007/WebServices/Execute"',
'Content-Type': 'text/xml'}
DEBUG:suds.transport.http:sending:
URL:http://client.service.host/MSCrmServices/2007/MetadataService.asmx
HEADERS: {'SOAPAction':
u'"http://schemas.microsoft.com/crm/2007/WebServices/Execute"',
'Content-Type': 'text/xml', 'Content-type': 'text/xml', 'Soapaction':
u'"http://schemas.microsoft.com/crm/2007/WebServices/Execute"'}
MESSAGE:
<SOAP-ENV:Envelope
xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://schemas.microsoft.com/crm/2007/WebServices"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<ns0:Body>
<ns1:Execute>
<ns1:Request xsi:type="ns1:RetrieveAttributeRequest">
<ns1:MetadataId>00000000-0000-0000-0000-000000000000</ns1:MetadataId>
<ns1:EntityLogicalName>opportunity</ns1:EntityLogicalName>
<ns1:LogicalName>new_typeofcontact</ns1:LogicalName>
<ns1:RetrieveAsIfPublished>false</ns1:RetrieveAsIfPublished>
</ns1:Request>
</ns1:Execute>
</ns0:Body>
</SOAP-ENV:Envelope>
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (16, 0))
---------------------------------------------------------------------------
URLError Traceback (most recent
call last)
/Users/crose/projects/2366/crm/<ipython console> in <module>()
/var/folders/nb/nbJAzxR1HbOppPcs6xO+dE+++TY/-Tmp-/python-67186icm.py in
<module>()
19 request.LogicalName = 'new_typeofcontact'
20 request.RetrieveAsIfPublished = 'false'
21
---> 22 attr = metadata_client.service.Execute(request)
23 print attr
/Users/crose/virtualenv/advanis/lib/python2.6/site-packages/suds/client.pyc
in __call__(self, *args, **kwargs)
537 return (500, e)
538 else:
--> 539 return client.invoke(args, kwargs)
540
541 def faults(self):
/Users/crose/virtualenv/advanis/lib/python2.6/site-packages/suds/client.pyc
in invoke(self, args, kwargs)
596 self.method.name, timer)
597 timer.start()
--> 598 result = self.send(msg)
599 timer.stop()
600 metrics.log.debug(
/Users/crose/virtualenv/advanis/lib/python2.6/site-packages/suds/client.pyc
in send(self, msg)
621 request = Request(location, str(msg))
622 request.headers = self.headers()
--> 623 reply = transport.send(request)
624 if retxml:
625 result = reply.message
/Users/crose/virtualenv/advanis/lib/python2.6/site-packages/suds/transport/https.pyc
in send(self, request)
62 def send(self, request):
63 self.addcredentials(request)
---> 64 return HttpTransport.send(self, request)
65
66 def addcredentials(self, request):
/Users/crose/virtualenv/advanis/lib/python2.6/site-packages/suds/transport/http.pyc
in send(self, request)
75 request.headers.update(u2request.headers)
76 log.debug('sending:\n%s', request)
---> 77 fp = self.u2open(u2request)
78 self.getcookies(fp, u2request)
79 result = Reply(200, fp.headers.dict, fp.read())
/Users/crose/virtualenv/advanis/lib/python2.6/site-packages/suds/transport/http.pyc
in u2open(self, u2request)
116 return url.open(u2request)
117 else:
--> 118 return url.open(u2request, timeout=tm)
119
120 def u2opener(self):
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.pyc
in open(self, fullurl, data, timeout)
381 req = meth(req)
382
--> 383 response = self._open(req, data)
384
385 # post-process response
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.pyc
in _open(self, req, data)
399 protocol = req.get_type()
400 result = self._call_chain(self.handle_open,
protocol, protocol +
--> 401 '_open', req)
402 if result:
403 return result
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.pyc
in _call_chain(self, chain, kind, meth_name, *args)
359 func = getattr(handler, meth_name)
360
--> 361 result = func(*args)
362 if result is not None:
363 return result
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.pyc
in http_open(self, req)
1128
1129 def http_open(self, req):
-> 1130 return self.do_open(httplib.HTTPConnection, req)
1131
1132 http_request = AbstractHTTPHandler.do_request_
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.pyc
in do_open(self, http_class, req)
1103 r = h.getresponse()
1104 except socket.error, err: # XXX what error?
-> 1105 raise URLError(err)
1106
1107 # Pick apart the HTTPResponse object to get the
addinfourl
URLError: <urlopen error [Errno 60] Operation timed out>
The cURL command is:
/opt/local/bin/curl --ntlm -u "domain\user.name:userpass" -k -d @-
-A "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR
1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR
3.5.21022; InfoPath.1)" -H "Connection: Keep-Alive" -H "Content-Type:
text/xml; charset=utf-8" -H "SOAPAction:
http://schemas.microsoft.com/crm/2007/WebServices/Execute"
https://client.service.host/MSCrmServices/2007/MetadataService.asmx
The data that is piped to that cURL command:
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<CrmAuthenticationToken
xmlns="http://schemas.microsoft.com/crm/2007/WebServices">
<AuthenticationType
xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">0</AuthenticationType>
<CrmTicket
xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes"></CrmTicket>
<OrganizationName
xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">CMIFS</OrganizationName>
<CallerId
xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">00000000-0000-0000-0000-000000000000</CallerId>
</CrmAuthenticationToken>
</soap:Header>
<soap:Body>
<Execute
xmlns="http://schemas.microsoft.com/crm/2007/WebServices">
<Request xsi:type="RetrieveAttributeRequest">
<MetadataId>00000000-0000-0000-0000-000000000000</MetadataId>
<EntityLogicalName>opportunity</EntityLogicalName>
<LogicalName>new_typeofcontact</LogicalName>
<RetrieveAsIfPublished>false</RetrieveAsIfPublished>
</Request>
</Execute>
</soap:Body>
</soap:Envelope>
Here's the response:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<ExecuteResponse
xmlns="http://schemas.microsoft.com/crm/2007/WebServices">
<Response xsi:type="RetrieveAttributeResponse">
<AttributeMetadata xsi:type="PicklistAttributeMetadata">
<MetadataId>101346cf-a6af-4eb4-a4bf-9c3c6bbd6582</MetadataId>
<SchemaName>New_TypeofContact</SchemaName>
<LogicalName>new_typeofcontact</LogicalName>
<EntityLogicalName>opportunity</EntityLogicalName>
<AttributeType>
<Value>Picklist</Value>
</AttributeType>
<!-- stuff here -->
</AttributeMetadata>
</Response>
</ExecuteResponse>
</soap:Body>
</soap:Envelope>
14 years, 1 month
may
by McNayr Heavilin
Ad held. "Ah--I thought so," said Bertie, "but you are changed about sometimes, a'nt you?" "Translations are occasionally made," said Dr. Proudie, "but not so frequently as in
former days." "They've cut them all down to pretty nearly the same figure,
haven't they?" said Bertie. To this
the bishop could not bring himself to make any answer, but again attempted to move
14 years, 1 month
Ead and butter and lodging." He laughed again. To lau
by Schettig
Iggled." "Giggled!" cried Phyllis, indignantly. Pembroke was laughing. "Yes, actually giggled," I went on. "I
laid down a twenty-five-cent piece, and you poured
but some water which had had nothing more than a mild flirtation with a lemon, and I gulped
it down. I held out my hand, and you said that there wasn't any change. I smiled a false smile. Let me ma
14 years, 1 month
Trouble with German ß, ä, ü, ö
by dunkel gruen
Hello,
i get an error messange if my input data contain a german 'umlaut' like
ä,ü,ö,ß. I try to change the encoding of my input data but nothing helps.
This is the error message:
return client.service.Validate(addBatchRequest)
File "c:\Python26\lib\site-packages\suds-0.3.9-py2.6.egg\suds\client.py",
line 539, in __call__
File "c:\Python26\lib\site-packages\suds-0.3.9-py2.6.egg\suds\client.py",
line 592, in invoke
File
"c:\Python26\lib\site-packages\suds-0.3.9-py2.6.egg\suds\bindings\binding.py",
line 118, in get_message
File
"c:\Python26\lib\site-packages\suds-0.3.9-py2.6.egg\suds\bindings\document.py",
line 63, in bodycontent
File
"c:\Python26\lib\site-packages\suds-0.3.9-py2.6.egg\suds\bindings\document.py",
line 105, in mkparam
File
"c:\Python26\lib\site-packages\suds-0.3.9-py2.6.egg\suds\bindings\binding.py",
line 260, in mkparam
File "c:\Python26\lib\site-packages\suds-0.3.9-py2.6.egg\suds\mx\core.py",
line 62, in process
File "c:\Python26\lib\site-packages\suds-0.3.9-py2.6.egg\suds\mx\core.py",
line 75, in append
File
"c:\Python26\lib\site-packages\suds-0.3.9-py2.6.egg\suds\mx\appender.py",
line 102, in append
File
"c:\Python26\lib\site-packages\suds-0.3.9-py2.6.egg\suds\mx\appender.py",
line 243, in append
File
"c:\Python26\lib\site-packages\suds-0.3.9-py2.6.egg\suds\mx\appender.py",
line 182, in append
File "c:\Python26\lib\site-packages\suds-0.3.9-py2.6.egg\suds\mx\core.py",
line 75, in append
File
"c:\Python26\lib\site-packages\suds-0.3.9-py2.6.egg\suds\mx\appender.py",
line 102, in append
File
"c:\Python26\lib\site-packages\suds-0.3.9-py2.6.egg\suds\mx\appender.py",
line 243, in append
File
"c:\Python26\lib\site-packages\suds-0.3.9-py2.6.egg\suds\mx\appender.py",
line 182, in append
File "c:\Python26\lib\site-packages\suds-0.3.9-py2.6.egg\suds\mx\core.py",
line 75, in append
File
"c:\Python26\lib\site-packages\suds-0.3.9-py2.6.egg\suds\mx\appender.py",
line 102, in append
File
"c:\Python26\lib\site-packages\suds-0.3.9-py2.6.egg\suds\mx\appender.py",
line 298, in append
File
"c:\Python26\lib\site-packages\suds-0.3.9-py2.6.egg\suds\mx\appender.py",
line 182, in append
File "c:\Python26\lib\site-packages\suds-0.3.9-py2.6.egg\suds\mx\core.py",
line 75, in append
File
"c:\Python26\lib\site-packages\suds-0.3.9-py2.6.egg\suds\mx\appender.py",
line 102, in append
File
"c:\Python26\lib\site-packages\suds-0.3.9-py2.6.egg\suds\mx\appender.py",
line 243, in append
File
"c:\Python26\lib\site-packages\suds-0.3.9-py2.6.egg\suds\mx\appender.py",
line 182, in append
File "c:\Python26\lib\site-packages\suds-0.3.9-py2.6.egg\suds\mx\core.py",
line 75, in append
File
"c:\Python26\lib\site-packages\suds-0.3.9-py2.6.egg\suds\mx\appender.py",
line 102, in append
File
"c:\Python26\lib\site-packages\suds-0.3.9-py2.6.egg\suds\mx\appender.py",
line 198, in append
File
"c:\Python26\lib\site-packages\suds-0.3.9-py2.6.egg\suds\sax\element.py",
line 251, in setText
File
"c:\Python26\lib\site-packages\suds-0.3.9-py2.6.egg\suds\sax\text.py", line
43, in __new__
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 9:
ordinal not in range(128)
Any hint?
Thanks
dunkegruen
14 years, 1 month
raised her eyes in a meek, resigne
by Slauson Wheelen
My feet on a slippery oilcloth as cold as ice. After about twenty
minutes (it seemed three hours and a half)--he came
in with a coat over his arm! _Agatha's coat_! I nearly swooned! ... "Now
you don't say so--really! Your sister's? And I made so sure it was yours! Isn't
that curious, now? I may say I have been in the tailoring trade, man and boy, for a matter
of twenty years, an' I never knew such a thing to occur before! Of course it wouldn't be any use saying I could make another
by Wednesday, for I should only disappoint,
but if Miss Hagatha was to run
over, such a thing as this hafternoon, she could have 'er's 'ome
in the place of yours." ... I got home _somehow_, I don't know how, for my mind was a blank, fell into bed, and lay prostrate until the next day, when hope revived once more. If the worst came to the worst, I was sure of a new voile dress which Miss Green was making,
and the old coat and skirt would do very well
for the mornings. The voile dress promised to be charming, for she really makes very well when she likes; so I felt restored to equanimity,
until at eleven o'clock, behold a small girl, to see Miss C Rendell--"Oh, if-- you--please--Miss Green--says--as--she's--two--yards--short--of--the-- material--and--could--you--make--it--convenient--to--get--it--to-day?" My brain reeled! As soon as I had sufficiently recovered, I rushed round to see her myself. "You _told_ me you only needed twelve
14 years, 1 month