2012-10-13 145 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,我忘了标记你的答案为已接受;) –