I have a PHP code that allows me to connect to a webservice and retrieve the response.
If I run this code locally on my computer without any particular configuration, it works. But as soon as I run it on my web server, I get this error:
The PHP version currently running is :
PHP 7.1.5 (cli) (built: May 9 2017 19:48:36) ( NTS MSVC14 (Visual C++ 2015) x64 ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
SOAP Fault: WSDL, SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://ws.chronopost.fr/shipping-cxf/ShippingServiceWS?wsdl' : failed to load external entity "https://ws.chronopost.fr/shipping-cxf/ShippingServiceWS?wsdl"
- I had an old version of PHP in 5.3.9, I modified to run one in 7.1.5, same error.
- I can connect to the webservice from Postman with my credentials.
- I tried to disable SSL verification in my code, same error.
- I can open the url from a server browser.
- The firewall doesn’t block anything in particular.
- I’ve managed to connect without error using nuSOAP, but I can’t retrieve the response returned by the webservice.
I’ve already done what is indicated in this answer: SOAP PHP fault parsing WSDL: failed to load external entity? and the result is the same. That’s why I’m asking this question.
How can I determine the cause of the problem?
Thanks for your help,
My code:
<?php
// Specify the full path to the PHP executable
$chemin_php = "C:\php\php7.1.5\php.exe";
// Execute the command to obtain the PHP version
$version_php = shell_exec("$chemin_php -v");
// Display PHP version
echo "The PHP version currently running is : <br>";
echo $version_php;
// URL du service WSDL
$wsdlUrl = 'https://ws.chronopost.fr/shipping-cxf/ShippingServiceWS?wsdl';
$requestUrl = 'https://ws.chronopost.fr/shipping-cxf/ShippingServiceWS';
// the soap operation which is called
$action = 'euExpressRateBook_providerServices_ShipmentHandlingServices_Binder_createShipmentRequest';
// the xml input of the service
$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>';
try {
$options = array();
$options['wrapper'] = array(
'soap_version' => 'SOAP_1_1',
'encoding' => 'UTF-8',
'user_agent' => 'PHPSoapClient',
// The exceptions option is a boolean value defining whether soap errors throw exceptions of type SoapFault.
'exceptions' => true,
// The trace option enables tracing of request so faults can be backtraced.
'trace' => true
);
$context = stream_context_create($options);
// create the soapclient and invoke __doRequest method
//WSDL URL is called on init
$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);
}
catch (SoapFault $fault) {
var_dump($fault);
echo "<h2>SOAP Fault!</h2><p>";
echo "FaultCode: {$fault->faultcode} <br/>";
echo "FaultString: {$fault->faultstring} <br/>";
echo("</p/>");
}