【发布时间】:2014-06-07 16:31:03
【问题描述】:
以下是请求 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,因此我在下面给出了链接
【问题讨论】:
-
您能否也包含来自此命名空间的 XSD 链接:
https://trtestr3xapi.navitaire.com/SessionManager.svc?xsd=xsd3?它无法从 WSDL 访问,它声明了您遇到问题的元素。 -
我不熟悉 SOAP 概念。能详细点吗?
-
您可以在本地访问的上述 URL 指向一个文件(XSD 架构)。它由您的 WSDL 自动导入。在其中有一个
ContractVersion的元素声明。如果您也可以发布该文件,它可能有助于诊断问题。 -
我认为它在此链接中可见 pastie.org/9263788 如果这不是您所指的那个,那么我需要询问 API 提供者。
-
在那个链接中您发布了 WSDL 文档。该文档包含以下标签:
<xsd:import schemaLocation="https://trtestr3xapi.navitaire.com/SessionManager.svc?xsd=xsd3" namespace="http://schemas.navitaire.com/WebServices"/>,它指的是 XSD,它描述了http://schemas.navitaire.com/WebServices命名空间中的元素。您发布的链接中没有关于ContractVersion的信息。该信息在 XSD 中。