views:

432

answers:

1

I have WSDL file, using that i wanted to make soap request which will look exactly like this --

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
  <soap:Header>
    <AuthSoapHd xmlns="http://foobar.org/"&gt;
      <strUserName>string</strUserName>
      <strPassword>string</strPassword>
    </AuthSoapHd>
  </soap:Header>
  <soap:Body>
    <SearchQuotes xmlns="http://foobar.org/"&gt;
      <searchtxt>string</searchtxt>
    </SearchQuotes>
  </soap:Body>
</soap:Envelope>

To sovle this, i did this

>> from SOAPpy import WSDL
 >> WSDLFILE = '/path/foo.wsdl'
 >> server = WSDL.Proxy(WSDLFILE)
 >> server.SearchQuotes('rel')

I get this error

faultType: <Fault soap:Server: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object.

The i debugged it and got this

*** Outgoing SOAP ******************************************************
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsd="http://www.w3.org/1999/XMLSchema"
>
<SOAP-ENV:Body>
<SearchQuotes SOAP-ENC:root="1">
<v1 xsi:type="xsd:string">rel</v1>
</SearchQuotes>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

We can see it doesn't contain any header. I think that WSDL file has some bug. Now, can anyone suggest me how to add header to this outgoing soap request.

Any sort of help will be appreciated. Thanks in advance

A: 

Not tested, but I believe you can use the method the docs suggest to add soap headers, i.e., make and prep a SOAPpy.Header instance, then use server = server._hd (hd) to get a proxy equipped with it (though in your case that does seem to be a workaround attempt to broken WSDL, as you say -- might it be better to fix the WSDL instead?).

Alex Martelli