2012-10-13 190 views
4

我想發送一個SOAP請求,但我收到一個錯誤,告訴我有些參數無效。下面的代碼:如何打印SOAP請求?

$client = new SoapClient('https://live.domainbox.net/?WSDL', array('soap_version' => SOAP_1_2)); 
$params = array(
    'AuthenticationParameters' => array(
     'Reseller' => 'reseller', 
     'Username' => 'username', 
     'Password' => 'password' 
    ), 
    'CommandParameters' => array(
     'DomainName' => 'mydomain.com', 
     'LaunchPhase' => 'GA' 
    ) 
); 

$result = $client->CheckDomainAvailability($params); 
print_r($result); 

這裏的錯誤消息:

stdClass Object 
(
    [CheckDomainAvailabilityResult] => stdClass Object 
     (
      [ResultCode] => 201 
      [ResultMsg] => Authentication Failed: Invalid Authentication Parameters 
      [TxID] => xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx 
      [AvailabilityStatus] => 3 
      [AvailabilityStatusDescr] => ErrorOccurred 
      [LaunchPhase] => GA 
      [DropDate] => 
      [BackOrderAvailable] => 
     ) 

) 

我希望看到發送到服務器,以確保它是很好格式化的請求。

下面是它的需要進行格式化:

<soap12:Envelope xmlns:xsi=」http://www.w3.org/2001/XMLSchema-instance」 
xmlns:xsd=」http://www.w3.org/2001/XMLSchema」 xmlns:soap12=」http://www.w3.org/2003/05/ 
soap-envelope」> 
<soap12:Body> 
    <CheckDomainAvailability xmlns=」https://live.domainbox.net/」> 
     <AuthenticationParameters> 
      <Reseller>myreseller</Reseller> 
      <Username>myuser</Username> 
      <Password>mypassword</Password> 
     </AuthenticationParameters> 
     <CommandParameters> 
      <DomainName>checkadomain.co</DomainName> 
      <LaunchPhase>GA</LaunchPhase> 
     </CommandParameters> 
    </CheckDomainAvailability> 
</soap12:Body> 
</soap12:Envelope> 

我如何可以打印已發送到服務器的請求?

我已經嘗試過:

echo $client->__getLastRequest(); 

但我什麼也沒得到,甚至在網頁的源代碼。

感謝

回答

4

添加跟蹤選項:

$client = new SoapClient('https://live.domainbox.net/?WSDL', array('trace' => true, 'soap_version' => SOAP_1_2)); 

然後__getLastRequest()應該工作。

+0

謝謝!對我很有用 – davidselo

+0

我是soprry,我忘了標記你的答案爲已接受;) –