How to request a response from XML-API SOAP?

I have never worked with a SOAP XML api before.

I read a couple of similar questions about SO, but I can't get it to work.

Here is a simple request:

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

I contacted them, but they do not offer a PHP API.

I would like to use the SoapClient class built into PHP.

Question: How to send a request and print the answer?

+1
source share
2 answers

It looks like your WSDL is located at https://live.domainbox.net/?WSDL .

Here is an example of using native 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); 
+7
source

To get this working, I needed to change the first line to get the correct soap version to 1.2. Also previous comment

 $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); 
+2
source

Source: https://habr.com/ru/post/1439241/


All Articles