我有一個XML格式。我需要使用PHP將SOAP請求發送到服務器。我試着用下面的代碼,但我看到錯誤。用PHP寫一個自定義XML的SOAP請求
請在這裏找到
樣品申請
<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>
的WSDL守則
<?php
$test->DomainCode = 'CODE';
$test->AgentName = 'AgentName';
$test->Password = 'Password';
$test->RoleCode = 'Role';
$wsdl = "https://trtestr3xapi.navitaire.com/sessionmanager.svc?wsdl";
$client = new SoapClient($wsdl);
try {
$logon_request = $client->Logon($test);
print_r($logon_request);
echo "success!";
}
catch (SoapFault $soap_error) {
echo $soap_error;
echo "error!";
}
?>
方法名稱是Logon。我也被給了另一個鏈接使用,但我該如何使用它?
https://trtestr3xapi.navitaire.com (The urls can't be view from all IPs)
我發送正確的請求嗎?
錯誤
SoapFault exception: [a:InternalServiceFault] Object reference not set to an instance of an object. in C:\Inetpub\vhosts\ezyflying.com\tiger\index.php:13 Stack trace: #0 C:\Inetpub\vhosts\ezyflying.com\tiger\index.php(13): SoapClient->__call('Logon', Array) #1 C:\Inetpub\vhosts\ezyflying.com\tiger\index.php(13): SoapClient->Logon(Array) #2 {main}error!
以下是我應該得到的響應。
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header />
<s:Body>
<LogonResponse xmlns="http://schemas.navitaire.com/WebServices">
<Signature>signature data</Signature>
</LogonResponse>
</s:Body>
</s:Envelope>
您不會使用SoapClient發送原始XML soap請求。它將本地對象轉換爲XML – Anthony
行。請查看與pastie鏈接提供的WSDL。你也可以幫我設置肥皂請求與適當的PHP代碼? –