I’m using an old version of PHP, 5.3.9. To get around TLS problems, I’m using nuSOAP to connect to a webservice.
The connection is ok but the response returned by the webservice is empty and I get no error.
With a more recent version of PHP I do this:
$client = new SoapClient($wsdlUrl, $options);
//Here we call REQUEST URL
$output = $client->__doRequest($xmlrequest, $requestUrl, $action, 1);
// Affichez la réponse SOAP
echo "Réponse SOAP :<br>";
echo htmlentities($output);
And I get the displayed response.
With nuSOAP I do this but the response is empty:
$response = $client->send($xmlrequest, $action, '', $requestUrl);
echo "Réponse de la méthode SOAP : ";
echo htmlentities($response);
How can I get the same result?
My entire code:
<?php
// Include the NuSOAP file
require_once('nusoap-0.9.5/lib/nusoap.php');
// Define the URL of the Web service
$wsdlUrl = 'https://ws.chronopost.fr/shipping-cxf/ShippingServiceWS?wsdl';
$requestUrl = 'https://ws.chronopost.fr/shipping-cxf/ShippingServiceWS';
// Create a NuSOAP client
$client = new nusoap_client($wsdlUrl, true);
// Check if there was an error during client creation
$err = $client->getError();
if ($err) {
// If there was an error during client creation, display the error message
echo "Error creating client: " . $err;
exit();
} else {
// If no error was detected, display "connection successful"
echo "Connection successful";
}
// Define the SOAP action and the content of the request
$action = 'euExpressRateBook_providerServices_ShipmentHandlingServices_Binder_createShipmentRequest';
$xmlrequest = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cxf="http://cxf.shipping.soap.chronopost.fr/">
<soapenv:Header/>
<soapenv:Body>
//rest of the code
</soapenv:Body>
</soapenv:Envelope>';
// Send the SOAP request
$response = $client->send($xmlrequest, $action, '', $requestUrl);
// Display the SOAP request response
echo "SOAP method response: ";
echo htmlentities($response);
Thanks for your help,