How to change namespace sent with SOAP request?

In connection with this question: How to request a response from the XML-API SOAP?

I have this PHP script sending a request with required fields:

$client = new SoapClient('https://live.domainbox.net/?WSDL'); $params = array( 'AuthenticationParameters' => array( 'Reseller' => 'resellername', 'Username' => 'myusername', 'Password' => 'mypassword' ), 'CommandParameters' => array( 'DomainName' => 'mydomain.com', 'LaunchPhase' => 'GA' ) ); $result = $client->CheckDomainAvailability($params); print_r($result); 

The following error message appears:

Fatal error: throw exception SoapFault: [soap: VersionMismatch]

Possible SOAP version mismatch: The envelope namespace http://schemas.xmlsoap.org/soap/envelope/ was unexpected.

Waiting for http://www.w3.org/2003/05/soap-envelope . at / home / nosa / public _html / dev / check-domain-availability.php: 20 Stack Next: # 0 / home / nosa / public _html / dev / check-domain-availability.php (20):

SoapClient → __ call ('CheckDomainAvai ...', Array) # 1 / home / nosa / public _html / dev / check-domain-availability.php (20): SoapClient-> CheckDomainAvailability (Array) # 2 {main} thrown in / home / nosa / public _html / dev / check-domain-availability.php on line 20

I uninstalled and recompiled apache to enable the latest version of SOAP available with WHM / cPanel.

My question is: How do I send the correct envelope namespace?

+4
source share
1 answer

When creating the soap_client object, you can pass an array of parameters, by default the version will be 1.1 in accordance with the php documentation.

You notice an error indicating that the service may be SOAP 1.2, so you need to set it to 1.2 ...

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

Try it!

+5
source

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


All Articles