微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php – 如何打印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();

但即使在页面的源代码中,我什么都没得到.

谢谢

解决方法:

添加跟踪选项:

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

然后__getLastRequest()应该工作.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐