How to print a SOAP request?

I am trying to send a SOAP request, but I get an error indicating that some parameters are invalid. Here is the code:

$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); 

This is where the error message appears:

 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] => ) ) 

I want the request to be sent to the server to make sure it is well-formed.

Here's how to form it:

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

How to print a request sent to the server?

I already tried:

 echo $client->__getLastRequest(); 

But I didn’t get anything, even in the source code of the page.

thanks

+4
source share
1 answer

Add trace function:

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

Then __getLastRequest() should work.

+4
source

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


All Articles