PHP https ssl SoapClient Error with Centos Upgrade - php

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!

Related

Failed to load external entity. SOAP WSDL parsing error

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?

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

SoapClient failing to load WSDL, needs apache restart to work again

Server is CENTOS with PHP 5.4 and Apache 2.2.
I have a SoapClient object like this:
$client = new \SoapClient(__DIR__ . "/wsdlfilehere.wsdl", array("soap_version"=>SOAP_1_2, "trace"=>true));
After awhile (within 24 hours), this code throws an error:
SOAP-ERROR: Parsing WSDL: Couldn't load from '/wsdlfilehere.wsdl' : failed to load external entity "/wsdlfilehere.wsdl".
Then after I restart apache and it works again.
Edit: even setting cache_wsdl to WSDL_CACHE_NONE doesn't fix the issue.
After digging around I finally found a workaround/solution.
Following this link on Ubuntu's launchpad it seems that other people are also experiencing this problem. I followed zabuch's instruction at comment #6 and it seems to work now. I agree with him that the issue might be on mod_php/php itself and not Ubuntu only, since I'm on CentOS and have experienced this problem.
From zabuch's comment:
The workaround for the issue is to add this:
libxml_disable_entity_loader(false);
before creating new SoapClient.

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;

Amazon S3 - deleteObjects() - "guzzle" errors?

Here's the reduced but accurate code I'm working with.
$client = S3Client::factory(array('key'=>$ak,'secret'=>$sk));
foreach(range(1,10) as $i) $temp[] = array('Key'=>$i);
$result = $client->deleteObjects(array('Bucket'=>'bucket','Objects'=>$temp));
return $result;
Everything works, it deletes the objects as requested but it throws all of these errors from the phar file. Running this locally as you can see below.
Fatal error: Uncaught exception 'Guzzle\Http\Exception\CurlException' with message '[curl] 56: Problem (2) in the Chunked-Encoded data [url] https://bucket.s3.amazonaws.com?delete=' in phar://C:/wamp/www/bucket/local/aws.phar/Aws/Common/Client/AbstractClient.php on line 285
Guzzle\Http\Exception\CurlException: [curl] 56: Problem (2) in the Chunked-Encoded data [url] https://bucket.s3.amazonaws.com?delete= in phar://C:/wamp/www/bucket/local/aws.phar/Guzzle/Http/Curl/CurlMulti.php on line 365
Aws\Common\Exception\TransferException: [curl] 56: Problem (2) in the Chunked-Encoded data [url] https://bucket.s3.amazonaws.com?delete= in phar://C:/wamp/www/bucket/local/aws.phar/Aws/Common/Client/AbstractClient.php on line 285
I was also having this problem running WampServer on Windows 7 x64. Through dumb luck, I just stumbled across the solution.
Simply add 'scheme' => 'http' to the factory config settings and it starts working!
Little late I realize, but searches for this returned very little, hopefully this might help someone else.
I was also getting this error only when trying to deleteObjects, WAMPSERVER (64 BITS & PHP 5.4) 2.4, Windows 7 x64. I think something is wrong with the Curl extension in this version of WAMP. I installed WAMPSERVER (32BITS & PHP 5.4) 2.4 and had no issues with deleteObjects.
Possible solution is to add
'curl.options' => array('CURLOPT_HTTP_VERSION'=>'CURL_HTTP_VERSION_1_0')
to S3Client::factory options.
No more mentioned curl errors, but now I sometimes receive Simple XML error: "Entity: line 2: parser error : Extra content at the end of the document".

Categories