gpt4 book ai didi

php - 无法使用 mustUnderstand 设置 SOAP header

转载 作者:数据小太阳 更新时间:2023-10-29 02:40:39 26 4
gpt4 key购买 nike

请求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 代码。

$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);

...

对于上面的代码,我得到以下错误。

SoapFault exception: [s:MustUnderstand] The header 'ContractVersion' from the namespace 'h' was not understood by the recipient of this message, causing the message to not be processed. This error typically indicates that the sender of this message has enabled a communication protocol that the receiver cannot process. Please ensure that the configuration of the client's binding is consistent with the service's binding.

我该如何解决这个问题?由于只能从特定 IP 访问 WSDL,我已提供以下链接

WSDL:http://pastie.org/9263788

最佳答案

语法,根据SOAPHeader文档,应该是:

SoapHeader ( string $namespace , string $name , mixed $data , bool $mustunderstand )

在您的代码中,您将命名空间前缀放在了命名空间应该位于的位置:

$header = new SoapHeader('h','ContractVersion','330', '1');

将该行更改为:

$header = new SoapHeader('http://schemas.navitaire.com/WebServices','ContractVersion','330', 'true');

关于php - 无法使用 mustUnderstand 设置 SOAP header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24099302/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com