0

我有 WSDL 文件,使用它我想发出一个看起来完全像这样的肥皂请求——

<?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/">
  <soap:Header>
    <AuthSoapHd xmlns="http://foobar.org/">
      <strUserName>string</strUserName>
      <strPassword>string</strPassword>
    </AuthSoapHd>
  </soap:Header>
  <soap:Body>
    <SearchQuotes xmlns="http://foobar.org/">
      <searchtxt>string</searchtxt>
    </SearchQuotes>
  </soap:Body>
</soap:Envelope>

为了解决这个问题,我这样做了

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

我收到这个错误

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.

我调试了它并得到了这个

*** 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>

我们可以看到它不包含任何标题。我认为 WSDL 文件有一些错误。现在,任何人都可以建议我如何将标头添加到这个传出的肥皂请求中。

任何形式的帮助将不胜感激。提前致谢

4

1 回答 1

0

未经测试,但我相信您可以使用文档建议的方法添加soap标头,即制作和准备一个SOAPpy.Header实例,然后使用server = server._hd (hd)它来获取配备它的代理(尽管在您的情况下,这似乎是一种解决方法尝试正如您所说,损坏的 WSDL 可能会更好地修复 WSDL 吗?)。

于 2009-09-26T18:23:32.410 回答