2012-10-11 80 views
1

我从来没有使用过SOAP XML API。如何从SOAP XML API请求答案?

我读过几个类似的问题,但我无法让它工作。

这里有一个简单的要求:

<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> 

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

我想使用PHP中构建的SoapClient类。

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

+1

显示的WSDL .. – MrCode

+0

我觉得有没有提供WSDL,全面的文档都可以在这里:https://admin.domainbox.net/docs/Domainbox-commands.pdf。我搜索了WSDL,并没有提及它。 –

回答

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); 
+0

WOOOW你是怎么发现的?我非常感谢,非常感谢MrCode! –

+0

Uhoh,它引发一个错误:未捕获SoapFault异常:[WSDL] SOAP-ERROR:解析WSDL:无法从“https://live.domainbox.net/?WSDL”加载:无法加载外部实体“https: //live.domainbox.net/?WSDL”。 (我更改设置以反映我的凭据) –

+0

你有链接中的报价吗?如果没有,那么这是一个服务器/网络问题 - 您的服务器没有外部访问权限,因此无法连接到WSDL。你的主人将能够提供帮助。 – MrCode

2

为了得到这个工作,我需要改变第一行来获得正确版本的肥皂到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); 
+0

感谢分享;)愉快的编码 –