[Soap-Python] suds: attribute of complex argument does not get namespace prefix

Thomas Hottendorff thomas.hottendorff at hvbo4.de
Thu Jun 12 15:31:26 CEST 2014


 0 down vote favorite
	

I'm trying to write a saop client to connect to the mks integrity soap
interface using python 2.7.3 and suds-jurko 0.6 (or suds-03.9).

However I'm stuck now with my first example because the attributes
transactionId and ItemId that belong to the complex argument I pass on with
the method lack the required namespace prefixes (ns1:...) in my example. So,
my question is, is there a means to add these?

Here's the code I have:

#!/usr/bin/env python
#
#
import logging
import suds
from suds.client import Client

# Send log messages to console
logging.basicConfig(level=logging.INFO)
# Set Suds logging level to debug, outputs the SOAP messages.
logging.getLogger('suds.client').setLevel(logging.DEBUG)

# Web service
url = "http://besrv-mks01.ta.global:7001/webservices/2009/Integrity/?wsdl"
headers = dict( SOAPAction = 'action' )
client = Client(url, headers = headers)

print client

getItemType = client.factory.create('ns5:GetItemType')
getItemType.Username = "some_user"
getItemType.Password = "secret"
getItemType.InputField = [ "Story Elaboration Notes" ]
getItemType._ItemId = "1554094"
getItemType._transactionId = "?"

print getItemType

try:
   result = client.service.getItem(getItemType)
except suds.WebFault, e:
  print e

This produces the following output:

--snip
(GetItemType){
   Username = "some_user"
   Password = "secret"
   ImpersonatedUser = None
   DateFormat = None
   DateTimeFormat = None
   _transactionId = "?"
   InputField[] =
      "Story Elaboration Notes",
   _ItemId = "1554094"
 }
DEBUG:suds.client:sending to
(http://besrv-mks01.ta.global:7001/webservices/2009/Integrity/)
message:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://webservice.mks.com/2009/Integrity/schema"
xmlns:ns2="http://webservice.mks.com/2009/Integrity"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <ns0:Body>
      <ns2:getItem>
         <arg0 transactionId="?" ItemId="1554094">    <== attributes here!
            <ns1:Username>some_user</ns1:Username>
            <ns1:Password>secret</ns1:Password>
            <ns1:InputField>Story Elaboration Notes</ns1:InputField>
         </arg0>
      </ns2:getItem>
   </ns0:Body>
</SOAP-ENV:Envelope>
DEBUG:suds.client:headers = {'SOAPAction': 'action', 'Content-Type':
'text/xml; charset=utf-8'}
DEBUG:suds.client:HTTP failed - 500 - Internal Server Error:
<env:Envelope
xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><env:Header></env:Header><env:Body><env:Fault
xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><faultcode>env:Server</faultcode><faultstring>Unable
to retrieve item null.</faultstring><detail><ns1:MKSException
class='java.lang.NullPointerException' implication='Unable to retrieve item
null.'
xmlns:ns1='http://webservice.mks.com/2009/Integrity/fault'/></detail></env:Fault></env:Body></env:Envelope>
ERROR:suds.client:<suds.sax.document.Document instance at 0x6ffff9ee758>
Server raised fault: 'Unable to retrieve item null.'

When I manually add the namespace prefix to the attributes and submit the
request via curl, I get the expected response.



More information about the Soap mailing list