1

我以前从未使用过 SOAP XML api。

我在 SO 上阅读了几个类似的问题,但我无法让它发挥作用。

这是一个简单的请求:

<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”&gt;
<soap12:Body>
<CheckDomainAvailability xmlns=”https://live.domainbox.net/”&gt;
<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>

我已经联系了他们,但他们不提供 PHP API。

我想使用 PHP 中内置的 SoapClient 类。

问题是:如何发送请求并打印答案?

4

2 回答 2

7

看起来您的 WSDL 位于https://live.domainbox.net/?WSDL.

这是一个使用原生 PHP SoapClient 的示例。

$client = new SoapClient('https://live.domainbox.net/?WSDL');

// populate the inputs....
$params = array(
    'AuthenticationParameters' => array(
        'Reseller' => '',
        'Username' => '',
        'Password' => ''
    ),
    'CommandParameters' => array(
        'DomainName' => '',
        'LaunchPhase' => ''
    )
);

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

print_r($result);
于 2012-10-11T17:03:43.183 回答
2

为了让它工作,我需要更改第一行以将正确版本的 soap 更改为 1.2。也是之前的评论

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

// populate the inputs....
    $params = array(
       'AuthenticationParameters' => array(
          'Reseller' => '',
          'Username' => '',
          'Password' => ''
        ),
        'CommandParameters' => array(
            'DomainName' => '',
            'LaunchPhase' => ''
        )
    );

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

print_r($result);
于 2014-05-23T09:05:25.897 回答