In this scenario, an individual encounters an issue while utilizing a SOAP client on a Linux server. While the code operates flawlessly on a WAMP server, it fails with an error message stating "SOAP-ERROR: Parsing WSDL: Couldn't load from."
The underlying problem, as identified by a knowledgeable respondent, lies in the SoapClient not transmitting HTTP user agent information in specific PHP versions. This results in the remote web service rejecting the request.
To rectify the situation, the respondent recommends explicitly setting the user agent within the code by employing a context stream:
$opts = array( 'http' => array( 'user_agent' => 'PHPSoapClient' ) ); $context = stream_context_create($opts); $wsdlUrl = 'http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl'; $soapClientOptions = array( 'stream_context' => $context, 'cache_wsdl' => WSDL_CACHE_NONE ); $client = new SoapClient($wsdlUrl, $soapClientOptions);
The respondent further observes that the concerned web service exhibits a peculiar behavior. Requests made over IPv6 without a user agent string fail, while those made with IPv4 or a user agent string succeed. This suggests a potential issue with the web service's configuration.
To verify this, the respondent demonstrates the difference in behavior when making HTTP requests with and without a user agent string:
curl -A '' -6 http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl
(fails)
curl -A 'cURL User Agent' -6 http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl
(succeeds)
Ultimately, the issue stems from the combination of IPv6 HTTP requests, inadequate user agent information in the SoapClient, and potential flaws within the web service itself.
The above is the detailed content of Why Does My SOAP Client Work on WAMP But Fail With 'SOAP-ERROR: Parsing WSDL: Couldn't load from' on Linux?. For more information, please follow other related articles on the PHP Chinese website!