Can enable I enable WS-RM (version 1.2) with NuSOAP client just like below? I tried this, but I cannot receive data from the API. Any ideas? Thanks.
$client = new nusoap_client($api_link, array('reliable' => 1.2 , 'useWSA' => TRUE) );
Full Code:
try {
include_once 'WebServiceSOAP/lib/nusoap.php';
$api_link = 'https://www.my-api.com/MYAPI.svc/SSL?wsdl';
$acode = '###';
$uname = '###';
$ttype = '###';
$ccode = '###';
$hpass = '###';
//setting xml request to api
$credentials = '<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/" xmlns:ezr="http://schemas.datacontract.org/2004/07/EzremitAPI.Entities">
<soapenv:Header/>
<soapenv:Body>
<tem:GetLocalRates>
<!--Optional:-->
<tem:credentials>
<!--Optional:-->
<ezr:AgentCode>'.$acode.'</ezr:AgentCode>
<!--Optional:-->
<ezr:HashedPassword>'.$hpass.'</ezr:HashedPassword>
<!--Optional:-->
<ezr:Username>'.$uname.'</ezr:Username>
</tem:credentials>
<!--Optional:-->
<tem:payincurcode>'.$ccode.'</tem:payincurcode>
<!--Optional:-->
<tem:transferType>'.$ttype.'</tem:transferType>
</tem:GetLocalRates>
</soapenv:Body>
</soapenv:Envelope>';
//creating soap object
$client = new nusoap_client($api_link, array('cache_wsdl' => WSDL_CACHE_NONE, 'soap_version' => SOAP_1_2) );
$client->soap_defencoding = 'UTF-8';
$soapaction = "http://tempuri.org/IRateAPI/GetLocalRates";
$xmlobjs = $client->send($credentials, $soapaction);
$err = $client->getError();
if ($err) {
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
exit();
}
//print_r($client);
print_r($xmlobjs);
}
catch(Exception $e) {
echo $e->getMessage();
}
?>
I'm not very good at PHP and SOAP. Above code may have errors. Could you please check the code and give me your comments. I have made some amendments after searching Google.
Also, can I run this on PHP 5.4.42? When I run above code, I get below error now.
Constructor error HTTP Error: Unsupported HTTP response status 415 Cannot process the message because the content type 'text/xml; charset=UTF-8' was not the expected type 'application/soap+xml; charset=utf-8'. (soapclient->response has contents of the response)
If anyone is looking for the answer to my above question, I found the solution with the help from @Marcel.
The answer to the question:
This code is wrong, don't use it.
NuSoap client is outdated and not supporting to WS-RM. I had to use PHP inbuilt SOAP extension to get my project worked.
Full answer in here: SOAP Error in PHP: OperationFormatter encountered an invalid Message body
Thanks