I\'m trying to run a web service using PHP & SOAP, but all I\'m getting so far is this:
(SoapFault)[2] message which states: \'SOAP-ERROR: Parsing
If anyone has the same problem, one possible solution is to set the bindto
stream context configuration parameter (assuming you're connecting from 11.22.33.44 to 55.66.77.88):
$context = [
'socket' => [
'bindto' => '55.66.77.88'
]
];
$options = [
'soapVersion' => SOAP_1_1,
'stream_context' => stream_context_create($context)
];
$client = new Client('11.22.33.44', $options);
After migrating to PHP 5.6.5, the soap 1.2 did not work anymore. So I solved the problem by adding optional SSL parameters.
My error:
failed to load external entity
How to solve:
// options for ssl in php 5.6.5
$opts = array(
'ssl' => array(
'ciphers' => 'RC4-SHA',
'verify_peer' => false,
'verify_peer_name' => false
)
);
// SOAP 1.2 client
$params = array(
'encoding' => 'UTF-8',
'verifypeer' => false,
'verifyhost' => false,
'soap_version' => SOAP_1_2,
'trace' => 1,
'exceptions' => 1,
'connection_timeout' => 180,
'stream_context' => stream_context_create($opts)
);
$wsdlUrl = $url . '?WSDL';
$oSoapClient = new SoapClient($wsdlUrl, $params);
The problem may lie in you don't have enabled openssl extention in your php.ini file
go to your php.ini file end remove ;
in line where extension=openssl
is
Of course in question code there is a part of code responsible for checking whether extension is loaded or not but maybe some uncautious forget about it
On register_client.php make sure that the URL that has been passed to SoapClient is accessible from the machine you're executing the code.
$sClient = new SoapClient('http://127.0.0.1/MyRegistration/login.wsdl');
If 127.0.0.0 does not work you can try using some network IP address and see.
Let me know if it still does not fix it for you, I did try with your example and changing path (making it proper in my dev. environment) has fixed same error for me.
I would be interested to know if it does not fix it for you.
Got a similar response with https WSDL URL using php soapClient
SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from ...
After server has been updated from PHP 5.5.9-1ubuntu4.21 >> PHP 5.5.9-1ubuntu4.23 something went wrong for my client machine osx 10.12.6 / PHP 5.6.30, but MS Web Services Clients connections could be made without issues.
Apache2's server_access.log showed no entry when i tried to load WSDL so i added 'cache_wsdl' => WSDL_CACHE_NONE
to prevent client-side wsdl caching, but still got no entries. Finally i tried to load wsdl per CURL -i
checked HEADERS but all seemed to be ok..
Only libxml_get_last_error()
provided some insight > SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
So I added some ssl options to my call:
$contextOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
));
$sslContext = stream_context_create($contextOptions);
$params = array(
'trace' => 1,
'exceptions' => true,
'cache_wsdl' => WSDL_CACHE_NONE,
'stream_context' => $sslContext
);
try {
$proxy = new SoapClient( $wsdl_url, $params );
} catch (SoapFault $proxy) {
var_dump(libxml_get_last_error());
var_dump($proxy);
}
In my case 'allow_self_signed' => true
did the trick!
I had the same problem, I succeeded by adding:
new \SoapClient(URI WSDL OR NULL if non-WSDL mode, [
'cache_wsdl' => WSDL_CACHE_NONE,
'proxy_host' => 'URL PROXY',
'proxy_port' => 'PORT PROXY'
]);
Hope this help :)