[Fedora-suds-list] Re: WSSE
Glenn Franxman
gfranxman at gmail.com
Wed Jan 28 16:41:49 UTC 2009
I'm stepping through the bindings code using pdb and I think I've
found a bug that is probably in the wsdl parser.
The wsdl for the service I am calling is here:
https://sandbox.amp.yahooapis.com/services/V1/LocationService?wsdl
I think the interesting bit is:
<wsdl:input name="getAccountLocationRequest">
<wsdlsoap:body use="literal"/>
<wsdlsoap:header message="tns:license" part="license" use="literal"/>
<wsdlsoap:header message="tns:accountID" part="accountID"
use="literal"/>
<wsdlsoap:header message="tns:Security" part="Security" use="literal"/>
</wsdl:input>
I'm stepping through the call to suds/bindings/binding.py part_types(
method, header=True )
308 B-> pts = self.part_types(method, header=True)
309 for header in headers:
310 if len(pts) == n: break
311 p = self.mkheader(method, pts[n], header)
312 if p is not None:
313 ns = pts[n][1].namespace()
...
> /usr/lib/python2.5/site-packages/suds/bindings/binding.py(346)part_types()
-> body = method.soap.input.body
(Pdb) l
341 @return: A list of parameter definitions
342 @rtype: [I{pdef},]
343 """
344 result = []
345 if input:
346 -> body = method.soap.input.body
347 if header:
348 parts = method.soap.input.header.message.parts
349 else:
350 parts = method.message.input.parts
351 else:
(Pdb) method.soap.input.header.message.parts
[(Part){
root = <wsdl:part name="license" element="tns:license"/>
name = "license"
qname[] =
"license",
"http://amp.yahooapis.com/V1",
element = "(u'license', u'http://amp.yahooapis.com/V1')"
type = "None"
}]
I think it ( and I ) are expecting
method.soap.input.header.message.parts to include tns:accountID and
tns:Security, not just tns:license.
The headers struct in suds/bindings/binding.py(308) headercontent() is:
(property:license = "...REMOVED...", property:accountID =
"...REMOVED...", (Security){
UsernameToken =
(UsernameToken){
Username = "REMOVED"
Password = "REMOVED"
}
})
I built the call like so:
client = Client( apt_wsdl )
### build account headers
license = client.factory.create('ns0:license')
license.set( License_Key )
accountid = client.factory.create('ns0:accountID')
accountid.set( Master_Account_Id )
sectoken = client.factory.create( 'ns1:Security' )
usernametoken = client.factory.create( 'ns1:UsernameToken' )
usernametoken.Username = Username
usernametoken.Password = Password
sectoken.UsernameToken = usernametoken
### apply the soap headers
client.set_options(soapheaders= (license, accountid, sectoken,) )
client.service.getAccountLocation( )
On Tue, Jan 27, 2009 at 6:56 PM, Glenn Franxman <gfranxman at gmail.com> wrote:
> Oops, I meant what happened to the accountID header, not license.
>
> On Tue, Jan 27, 2009 at 6:55 PM, Glenn Franxman <gfranxman at gmail.com> wrote:
>> I'm only just getting started with SOAP, so forgive the n00b questions.
>>
>> I'm trying to create calls that look something along the lines of:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>> xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/07/secext"
>> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xmlns="http://amp.yahooapis.com/V1">
>> <soapenv:Header>
>> <wsse:Security>
>> <wsse:UsernameToken>
>> <wsse:Username>user</wsse:Username>
>> <wsse:Password>password</wsse:Password>
>> </wsse:UsernameToken>
>> </wsse:Security>
>> <license>3cf33e7-5ad1-3a9-093-3681f55eb0</license>
>> <accountID>9966673</accountID>
>> </soapenv:Header>
>> <soapenv:Body>
>> ...
>> </soapenv:Body>
>> </soapenv:Envelope>
>>
>> To that end, I'm trying to add clauses for wsse:Security, license and accountID.
>> That section of my code looks like:
>>
>> ...
>> #construct WS-Security header for username/password
>> WSSE_NS = "http://schemas.xmlsoap.org/ws/2002/07/secext"
>> client.add_prefix( 'wsse', WSSE_NS )
>>
>> #build account headers
>> license = client.factory.create('license')
>> license.set( License_Key )
>> accountid = client.factory.create('accountID')
>> accountid.set( Master_Account_Id )
>>
>> client.set_options(soapheaders=( license, accountid))
>> ...
>>
>> and it is resulting in:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <SOAP-ENV:Envelope xmlns:ns0="http://amp.yahooapis.com/V1"
>> xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xmlns:tns="http://amp.yahooapis.com/V1"
>> xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
>> <SOAP-ENV:Header>
>> <tns:license>...</tns:license>
>> </SOAP-ENV:Header>
>> <SOAP-ENV:Body>
>> ...
>> </SOAP-ENV:Body>
>> </SOAP-ENV:Envelope>
>>
>> I'm still trying to feel my way through this, but I'm already wondering:
>>
>> What happened to the wsse namespace that I added?
>> What happened to the license header that I added?
>>
>> Has anyone successfully used WSSE with suds?
>>
>
More information about the fedora-suds-list
mailing list