服务器无法识别 SOAP 标头

时间:2021-03-04 21:08:11

标签: post soap

我正在使用 python 通过 POST 向 Web 服务发送 SOAP 消息。但是,虽然我看到我在 <SOAP-ENV:Header> 中设置了一个 text/xml 元素,但我从 Web 服务中得到一个错误,即特定的标头不存在。我调用服务如下:

url = '[url]'
headers = {
    'Content-Type' : 'text/xml',
}
body = get_soap_envelope()
response = requests.post(url,data=body,headers=headers)

在 XML 文档中,我看到

 <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header>
    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
     ...
   </wsse:Security>
   <ns1:WebServiceHeader xmlns:ns1="[...]" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="id-header">
    ...
   </ns1:WebServiceHeader>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body Id="id-body">
   ...
  </SOAP-ENV:Body>
 </SOAP-ENV:Envelope>

WebServiceHeader 是 Web 服务所需的 SOAP 标头。我清楚地看到此标头存在于我的 XML 文档中,但我收到错误消息:

 <wn0:ErrorMessageTxt i:type="d:string">WebServiceHeader element not found in the SOAP header.</wn0:ErrorMessageTxt>

这个错误是由于在 python 中发布 text/xml 还是网络服务的问题?使用 python 发布 <SOAP-ENV:Header> 时,text/xml 元素是否得到适当处理?这可能是命名空间问题吗?

0 个答案:

没有答案