Failed to load external entity. SOAP WSDL parsing error - php

We have this Windows Server 2008 R2 on which a webapplication is running using ZendFramework 2, PHP 5.4.34 and Apache 2.4.3 on which also a SOAP webservice is active.
But after migrating the source code to a Windows 2019 server with a newer PHP 7.4.24, the webservice seems to be faulty and following error message is shown :
[WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'HTTPS://xxx/xxx/xxx/AuthenticateTaskService/V1/auth?wsdl' : failed to load external entity
The code where the webservice is called:
$soapAuth = new SoapClient("HTTPS://xxx/xxx/xxx/AuthenticateTaskService/V1/auth?wsdl", array('soap_version' => SOAP_1_2, 'trace' => 1, 'exceptions' => true, 'style' => SOAP_DOCUMENT, 'use' => SOAP_LITERAL, 'encoding' => 'UTF-8'));
var_dump($soapAuth);
I have used both the webservice page on the newer server as the one on the older server, both having the same error.
Does anybody know what might be the cause here?
I've searched plenty of StackOverflow and other internet pages, but can't seem to pinpoint the exact cause. I was thinking I might be because of a newer PHP version?

Related

Why is my PHP SoapClient::__soapCall() taking 5-6 seconds?

I have a web application that consumes multiple SOAP APIs. I'm running PHP (7.2.34) and using SoapClient to connect to the API. Recently my hosting provider, MediaTemple, performed some mandatory updates and directly after that, for reasons I am unable to determine, one of the APIs now takes 5+ seconds to make a __soapCall() when the request is initiated from the browser on a site running PHP 7.2. I have multiple subdomains on my server 2 are running PHP 7.2 and the others PHP 8.0. It is only when a request is initiated from the browser and only on the subdomains running on PHP 7.2 that I am experiencing these delays. I've tested making calls to this API through the terminal, with Postman and through the subdomains running PHP 8.0 and in none of those setups is there any delay to speak of.
Here's the code that I have been using for some time now with no issues (at least 2-3 years).
$soapClient = new SoapClient($wsdl_location, [
'location' => $location,
'connection_timeout' => 5,
'cache_wsdl' => WSDL_CACHE_DISK,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
]);
$arguments = []; // array of arguments to pass with the request
$response = json_decode(json_encode($soapClient->__soapCall($endpoint, [$arguments])), true);
I have tried decreasing "connection timeout", deleting the cached WSDL files and adding the options below to the SoapClient options but this last attempt actually seemed to increase the call time by a second or two.
'stream_context' => stream_context_create([
'http' => [
'protocol_version' => '1.1',
'header' => 'Connection: Close',
],
])
The thing that has me baffled the most is that this issue only affects 1 API and only occurs when called from a browser on a website running PHP 7.2.

How to fix SOAP-ERROR parsing wsdl in php 7

I am migrating my application from php 5 to php 7.2.
I have a problem with theSoapclient call knowing that it works correctly with php 5.
After a lot of research I am progressing on my soapClient script with php 7.2, but I have a concern for stability.
The script will load the wsdl a few times, like 1 time out of 40 and then indicate a loading problem.
[message:protected] => SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://ip?WSDL' : failed to load external entity "http://ip?WSDL"
I added the stream_context , cache_wsdl options but no stable result!
it worked twice with this code bellow
$option = array (
'location' => $optionSc['location'],
'uri' => $optionSc['location'],
'login' => $optionSc['login'],
'password' => $optionSc['password'],
'trace' => 1,
'connection_timeout' => 0,
'exceptions' => 1
);
after that it returns like I described first.
anyone can help me with that if he fixed this problem I did a lot of researches but nothing is working fine and I am relly blocked!
I've experienced a similar behaviour. PHP was reporting errors with parsing remote WSDL.
The problem was weak certificate used by the remote server that kept being refused by OpenSSL, even before being processed by PHP.
Problem
I have confirmed this by trying to download the WSDL using curl
curl REMOTE_ADDRESS
which reported the following error
error:14082174:SSL routines:SSL3_CHECK_CERT_AND_ALGORITHM:dh key too small.
The diffie-hellman key base was 1024 instead of recommended 2048 which I checked using openssl command (see https://weakdh.org/)
openssl s_client -showcerts -connect admonitoring.mediaresearch.cz:443 </dev/null
Solution
Until the certificate problem is fixed and a new one, more secure, issued, I have managed to fix this problem by temporarily lowering Openssl security settings.
In /etc/ssl/openssl.cnf (Debian) comment out the following line
# comment out the following line in /etc/ssl/openssl.cnf
CipherString = DEFAULT#SECLEVEL=2
# or set SECLEVEL to 1
CipherString = DEFAULT#SECLEVEL=1
Instead of changing the settings on the whole system, I solved it by using:
$options['ssl']['ciphers'] = 'DEFAULT#SECLEVEL=1';
in the stream_context

SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://10.31.1.106:8080/gss-0.1/FileUtilities?wsdl'

I hope someone can help me because I am looking for the solution since 2 working days...
I have a php website which need to request a distant webservice.
When I try it on my computer (Win7 + WAMP), it works well.
When I try it on the webserver (CentOs6), it return me the following error :
SOAP-ERROR: Parsing WSDL: Couldn't load from
'http://ip_address:8080/gss-0.1/FileUtilities?wsdl' : failed to load
external entity "http://ip_address:8080/gss-0.1/FileUtilities?wsdl"
NB: the webservice is on the same network of my webserver (I do not use the same IP/port).
I know that the WSDL is accessible from the webserver because it is accessible using curl linux function.
curl http://ip_address:8080
My php code is:
<?php
$wsdl = "http://ip_address:8080/gss-0.1/FileUtilities?wsdl";
try{
$client = new SoapClient($wsdl ,array('trace' => 1,
'exceptions'=> 1,
'cache_wsdl' => WSDL_CACHE_NONE
));
}
catch(Exception $e) {
echo $e->getMessage();
}?>
OK I found a solution but I don't understand the problem...
So I execute this Linux command
setsebool -P httpd_can_network_connect on
And now all is running !
Response here: Thanks to user2533111
If its not firewalled there at your web server and its working in your local but not at your webserver(CentOS). its might be a case of different PHP version and php.ini settings.
Can you compare your PHP version and those below extensions in your CentOs server with your WAMP at local.
S0AP,
php_openssI,
openssI,
curI;

PHP https ssl SoapClient Error with Centos Upgrade

I have a PHP script that pulls orders from ChannelAdvisor using the SoapClient and has worked perfect for the past year. I upgraded our Centos 6 server and now the script does not work. It looks like it may be an OpenSSL issue from what I have gathered on the Internet. I moved the script to a server that I haven't upgraded yet and it works like a champ. I have also noticed that I can no longer "wget" any HTTPS addresses without it erroring out.
$client = new SoapClient('https://api.channeladvisor.com/ChannelAdvisorAPI/v6/OrderService.asmx?WSDL', array('trace' => true, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, 'connection_timeout' => '2'));
This is error I am getting...
PHP Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://api.channeladvisor.com/ChannelAdvisorAPI/v6/OrderService.asmx?WSDL' : failed to load external entity "https://api.channeladvisor.com/ChannelAdvisorAPI/v6/OrderService.asmx?WSDL" in get-orders-test.php on line 9
Any help is appreciated!

php soap client with a local wsdl call

I´m a newbie to soap in php, so I apologize if I´m not precise in my description.
I have working soap clients consuming wsdl´s in a providers remote server (eg www.remoteaddress.com/wsdl/webservice.wsdl). I was wondering if I could speed up that first wsdl call (before getting it into de cache) by downloading that wsdl from the remote server and uploading it locally to the same folder that contains the php that makes the call.
php.net says...
$client = new SoapClient(null, array('location' => "http://localhost/soap.php",
'uri' => "http://test-uri/",
'style' => SOAP_DOCUMENT,
'use' => SOAP_LITERAL));
So, questions please...does the location always have to be an http address or can a local apache server address be used (so as to reference a folder on a higher level than the public_html)? or in other words how do I reference in "location" the folder containing the the local uploaded wsdl? Would this speed things up, and if the local wsdl is in a public directory in my local server, does that pose some sort of security risk? Tried some combinations with the localhost above but none worked...
Thanks in advance for your help,
Pablo

Categories