无法使用 mustUnderstand 设置 SOAP 标头 [英] Unable to set SOAP header with mustUnderstand
本文介绍了无法使用 mustUnderstand 设置 SOAP 标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下是请求 XML
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://schemas.navitaire.com/WebServices/ISessionManager/Logon</Action>
<h:ContractVersion xmlns:h="http://schemas.navitaire.com/WebServices">330</h:ContractVersion>
</s:Header>
<s:Body>
<LogonRequest xmlns="http://schemas.navitaire.com/WebServices/ServiceContracts/SessionService">
<logonRequestData xmlns:d4p1="http://schemas.navitaire.com/WebServices/DataContracts/Session" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<d4p1:DomainCode>WWW</d4p1:DomainCode>
<d4p1:AgentName>API****</d4p1:AgentName>
<d4p1:Password>********</d4p1:Password>
<d4p1:LocationCode i:nil="true" />
<d4p1:RoleCode>APIB</d4p1:RoleCode>
<d4p1:TerminalInfo i:nil="true" />
</logonRequestData>
</LogonRequest>
</s:Body>
</s:Envelope>
以下是我的 PHP 代码.
And following is my PHP code.
$test->DomainCode = 'WWW';
$test->AgentName = 'AGENT';
$test->Password = 'PASS';
$test->RoleCode = 'ROLE';
$wsdl = "https://trtestr3xapi.navitaire.com/sessionmanager.svc?wsdl";
$client = new SoapClient($wsdl, array('trace' => 1));
$header = new SoapHeader('h','ContractVersion','330', '1');
$client->__setSoapHeaders($header);
...
对于上面的代码,我收到以下错误.
For the above code I get the following error.
SoapFault 异常:[s:MustUnderstand] 此消息的收件人无法理解命名空间h"中的标头ContractVersion",从而导致无法处理该消息.此错误通常表示此消息的发送方启用了接收方无法处理的通信协议.请确保客户端绑定的配置与服务的绑定一致.
我该如何解决这个问题?由于只能从特定 IP 访问 WSDL,因此我提供了以下链接
How do I fix this issue? Since the WSDL can only be accessed from a specific IP i have given the link below
WSDL:http://pastie.org/9263788
推荐答案
语法,根据 SOAPHeader 文档,应该是:
The syntax, according to the SOAPHeader documentation, should be:
SoapHeader ( string $namespace , string $name , mixed $data , bool $mustunderstand )
在您的代码中,您将命名空间前缀放在命名空间应该在的位置:
In your code, you placed the namespace prefix where the namespace should be:
$header = new SoapHeader('h','ContractVersion','330', '1');
将该行更改为:
$header = new SoapHeader('http://schemas.navitaire.com/WebServices','ContractVersion','330', 'true');
这篇关于无法使用 mustUnderstand 设置 SOAP 标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文