Unable to set SOAP header with mustUnderstand

蹲街弑〆低调 提交于 2019-12-23 18:04:25

问题


Following is the Request 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>

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

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


回答1:


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

Change that line to:

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


来源:https://stackoverflow.com/questions/24099302/unable-to-set-soap-header-with-mustunderstand

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!