get string repr of results to send via other transport?
by David Carmean
I had been working with suds a few months ago on a project which has been
deferred. Now I find myself working on another project wherein the author
had tried to use suds but it doesn't fit well with the rest of the code
(for one thing, twisted.web is the required transport).
Is it possible to use suds to create the request and then, instead of
having suds send it, dump the header/body to a string to handle with
another transport?
Could the inverse be done as well? Pass in a string buffer instead of a
live network transport/handle?
Thanks.
11 years, 8 months
Write type on WSSE
by Danilo Chilene
Hello,
I'm trying to adapt
https://github.com/conover/BBLearnWS/blob/master/demo.pythis script to
my webservice because I need add a type tag on WSSE.
Below is my script:
#!/usr/bin/python
from suds.client import *
from suds.wsse import *
from suds.plugin import Plugin
from suds.sax.element import Element
url = 'file:///Webservice.wsdl'
#client = Client(url)
security = Security()
class TypePlugin(Plugin):
def sending(self, context):
password =
context.envelope.childAtPath('Header/Security/UsernameToken/Password')
password.set('Type', 'Type=
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-pr...
')
token = UsernameToken('myuser', 'mypasswd')
security.tokens.append(token)
client = Client(url)
client.set_options(wsse=security, autoblend = True, plugins =
[TypePlugin()])
import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
logging.getLogger('suds.transport').setLevel(logging.DEBUG)
print client.service.ContactQueryPage()
Abaixo output:
[danilo@napmon01 crm]$ python webservice.py
DEBUG:suds.client:sending to (
https://secure-ausomxkwa.crmondemand.com/Services/Integration)
message:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="urn:crmondemand/ws/ecbs/contact/10/2004"
xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsse="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext..."
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="
http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<wsse:Security mustUnderstand="true">
<wsse:UsernameToken>
<wsse:Username>myuser</wsse:Username>
<wsse:Password>mypasswd</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</SOAP-ENV:Header>
<ns1:Body>
<ns0:ContactQueryPage_Input>
<ns0:ListOfContact/>
</ns0:ContactQueryPage_Input>
</ns1:Body>
</SOAP-ENV:Envelope>
DEBUG:suds.client:headers = {'SOAPAction':
'"document/urn:crmondemand/ws/ecbs/contact/10/2004:ContactQueryPage"',
'Content-Type': 'text/xml; charset=utf-8'}
DEBUG:suds.transport.http:sending:
URL:https://secure-ausomxkwa.crmondemand.com/Services/Integration
HEADERS: {'SOAPAction':
'"document/urn:crmondemand/ws/ecbs/contact/10/2004:ContactQueryPage"',
'Content-Type': 'text/xml; charset=utf-8', 'Content-type': 'text/xml;
charset=utf-8', 'Soapaction':
'"document/urn:crmondemand/ws/ecbs/contact/10/2004:ContactQueryPage"'}
MESSAGE:
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
xmlns:ns0="urn:crmondemand/ws/ecbs/contact/10/2004" xmlns:ns1="
http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsse="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext..."
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="
http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header><wsse:Security
mustUnderstand="true"><wsse:UsernameToken><wsse:Username>CVCBRASIL/MONITOR</wsse:Username><wsse:Password>cvc123monitor</wsse:Password></wsse:UsernameToken></wsse:Security></SOAP-ENV:Header><ns1:Body><ns0:ContactQueryPage_Input><ns0:ListOfContact/></ns0:ContactQueryPage_Input></ns1:Body></SOAP-ENV:Envelope>
ERROR:suds.client:<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="urn:crmondemand/ws/ecbs/contact/10/2004"
xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsse="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext..."
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="
http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<wsse:Security mustUnderstand="true">
<wsse:UsernameToken>
<wsse:Username>myuser</wsse:Username>
<wsse:Password>mypasswd</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</SOAP-ENV:Header>
<ns1:Body>
<ns0:ContactQueryPage_Input>
<ns0:ListOfContact/>
</ns0:ContactQueryPage_Input>
</ns1:Body>
</SOAP-ENV:Envelope>
DEBUG:suds.client:http failed:
<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="
http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Client</faultstring><detail><ErrorCode>SBL-ODU-01008</ErrorCode><ErrorMessage>The
HTTP request did not contain well-formed XML. An attempt to parse it
produced the following error: wsse:Password must specify a
Type.</ErrorMessage></detail></soap:Fault></soap:Body></soap:Envelope>
Traceback (most recent call last):
File "check_crm.py", line 25, in ?
print client.service.ContactQueryPage()
File "/usr/lib/python2.4/site-packages/suds/client.py", line 542, in
__call__
return client.invoke(args, kwargs)
File "/usr/lib/python2.4/site-packages/suds/client.py", line 602, in
invoke
result = self.send(soapenv)
File "/usr/lib/python2.4/site-packages/suds/client.py", line 657, in send
result = self.failed(binding, e)
File "/usr/lib/python2.4/site-packages/suds/client.py", line 718, in
failed
raise Exception((status, reason))
Exception: (400, u'Bad Request')
Any idea how I can specify the Type?
Thanks
11 years, 8 months
SOAP Header?
by Greg Lindstrom
Hello-
I'm learning suds and am having a bit of trouble with the "SOAP Header". I
have a php version of the customer's interface which defines a "new
SoapHeader(<their url>, 'authorizationInfo', <authorizationInfo Object>)"
and the "sets" the soap header in the recently created ProcessingService
object.
Is there a header common to all SOAP objects or is this something that the
client defines as part of their service?
Thanks for your help,
--greg
11 years, 9 months
MessagePlugin.reply() and __inject
by Michael McFadden
Hello... Looking for some help and some wisdom, and potentially a
feature request.
Using inject like so works GREAT! I can test so easily. Thank you for
__inject
result =
client.service,GetReport(reportID,__inject={'reply':self.fakeXMLdata})
And thank you for messagePlugin, because the service I use doesn't treat
UTF very well:
client = Client(self.__wsdlurl, plugins=[UnicodeFilter()])
But using both of these together doesn't seem to work - the filter is
not run (UnicodeFilter.received()) when I use __inject. The code looks
like it's 'skipped'.
I haven't done a huge spelunk into client.py to see exactly what's
happening, but it would really be nice if this could work... or maybe
I'm missing something?
To test:
Set up a messagePlugin that provides the 'received()' method
Note that received() is run when you do a request to a soap service.
create some fake XML data, pass it in via __inject - like above
Note that received() is NOT RUN.
I should mention that my soap provider is mean and actually charges for
every request/reply. So this would be a big money saver if I can get it
to work properly.
Otherwise, I'm stuck writing code to test my filters some other way and
can't regression test.
Any suggestions? Can someone repeat this behavior?
Suds ( https://fedorahosted.org/suds/ ) version: 0.4 GA build:
R699-20100913
11 years, 9 months
TypeNotFound problem
by Milad Rastian
Hi,
I know that you are sick of answering this question but really I couldn't
figure out how can I import the location
I followed the TipsAndTricks page
*from suds.client import Client*
from suds.xsd.sxbasic import Import
ns = 'http://schemas.xmlsoap.org/soap/encoding/'
location = 'http://schemas.xmlsoap.org/soap/encoding/'
Import.bind(ns, location)
ns = 'http://www.w3.org/2001/XMLSchema'
location='http://www.w3.org/2001/XMLSchema.xsd'
Import.bind(ns, location)
client = Client(url)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/suds-0.4.1-py2.7.egg/suds/client.py",
line 119, in __init__
sd = ServiceDefinition(self.wsdl, s)
File "/usr/local/lib/python2.7/dist-packages/suds-0.4.1-py2.7.egg/suds/servicedefinition.py",
line 57, in __init__
self.addports()
File "/usr/local/lib/python2.7/dist-packages/suds-0.4.1-py2.7.egg/suds/servicedefinition.py",
line 85, in addports
method = (m.name, binding.param_defs(m))
File "/usr/local/lib/python2.7/dist-packages/suds-0.4.1-py2.7.egg/suds/bindings/rpc.py",
line 39, in param_defs
return self.bodypart_types(method)
File "/usr/local/lib/python2.7/dist-packages/suds-0.4.1-py2.7.egg/suds/bindings/binding.py",
line 441, in bodypart_types
raise TypeNotFound(query.ref)
suds.TypeNotFound: Type not found: '(array, http://www.w3.org/2001/XMLSchema, )'
you can find the wsdl here https://gist.github.com/1552902
thanks,
--
/--------------------
Milad Rastian
11 years, 9 months