soap - python suds Error in XML -


i tryied couple of hours receive data soap webservice.

this code:

from suds.client import client suds import webfault  wsdl_url = 'gatewaywebservice.asmx?wsdl' client = client(wsdl_url)  checkifexists = client.factory.create('checkifexists') checkifexists.sessionid = '' checkifexists.userid = 'ttester@email.com' try:    response = client.service.customerservice(checkifexists)    #print response    if response.error:       print response.error    else:       pass except webfault, e:   print e print client.last_sent() print client.last_received() 

this sent:

<soap-env:envelope xmlns:ns0="asdf"                                                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:customerservice>          <ns0:customerservice>             <ns0:sessionid></ns0:sessionid>             <ns0:userid>ttester@email.com</ns0:userid>          </ns0:customerservice>       </ns0:customerservice>    </ns1:body> </soap-env:envelope> 

and webserver expect:

<?xml version="1.0" encoding="utf-8"?> <gateway xmlns="urn:software-com:gateway:v7-00"> <customerservice>     <checkifexists>         <sessionid/>         <userid>test</userid>     </checkifexists> </customerservice> </gateway> 

how can update code send valid request?

thanks in advance

you can implement suds plugin modify xml before sent.

in example below <soap-env:envelope> tag modified match webserver expectations:

from suds.client import client suds.plugin import messageplugin  class myplugin(messageplugin):     def marshalled(self, context):         envelope = context.envelope         envelope.name = 'gateway'         envelope.setprefix(none)         envelope.nsprefixes = {'xmlns' : 'urn:software-com:gateway:v7-00'}         # , on...         # envelope[0] header tag, envelope[1] body tag         # can use "print context.envelope" view modified xml  client = client(wsdl_url, plugins=[myplugin()]) 

you have complete marshalled method transform xml. before doing that, check if have correct wsdl file, @martijn pieters says.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -