I'm using Wsdl2PhpGenerator to create my soap client; was was working fine with PHP v5.4, but now I've upgraded to PHP 7 I get an error:
Uncaught SoapFault: SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://sussexbedcentre.retailsystem.net/services/v2/GetCatalog.asmx?WSDL' : failed to load external entity
I have tried:
Connecting to a non SSL soap service - worked fine, so must be the SSL.
Every ssl_method
soap.wsdl_cache_enabled, soap.wsdl_cache_ttl, soap.wsdl_cache all set to 0
Verified openssl, soap, xmlrpc php extensions all loaded ok
PEM file and passphrase worked fine under PHP 5.4
Any ideas what else I can try to get to the bottom of this?
Code I'm using is:
$cert = 'rs_ssl.pem';
$generator = new \Wsdl2PhpGenerator\Generator();
$generator->generate(
new \Wsdl2PhpGenerator\Config(array(
'inputFile' => 'https://sussexbedcentre.retailsystem.net/services/v2/GetCatalog.asmx?WSDL',
'outputDir' => 'soapclass/',
'soapClientOptions' => array(
'local_cert' => $cert,
'passphrase' => '*******',
'connection_timeout' => 60,
'trace' => 1,
'soap_version' => SOAP_1_2
)
))
);
If I switch back to PHP 5.4 with the same code it works fine.
Thanks!
Related
I'm trying to send a soap request to some url. My SOAP options are:
array(
'location' => 'https://some_url/',
'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
'trace' => 1,
'soap_version' => SOAP_1_2,
'connection_timeout' => 60,
'stream_context' => stream_context_create([
'ssl' => [
'verify_peer' => true,
'verify_peer_name' => true,
'allow_self_signed' => true,
'cafile' => 'cacert.crt', // This file really exists, checked that
]
])
);
I get the following error:
SoapClient::__doRequest(): SSL operation failed with code 1. OpenSSL Error messages:
error:0407006A:rsa routines:RSA_padding_check_PKCS1_type_1:block type is not 01
error:04067072:rsa routines:RSA_EAY_PUBLIC_DECRYPT:padding check failed
error:0D0C5006:asn1 encoding routines:ASN1_item_verify:EVP lib
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
So I googled for "block type is not 01", but the results are pretty scarce. One might think that ca cert is wrong, but I fetched it with Chromium's Developer tools (Security tab) when I was on a page representing my url. Just to make sure that it's ok I put it in my browser and that page opens without any security warnings, showing me an XML response.
Putting it in /usr/share/ca-certificates/ had no effect either.
Certificate has pem encoding.
verify_peer set to false is not an option of course.
My php version is 5.5.17-2, the same behaviour is observed on PHP 7.0.21-1 though. OS is Ubuntu 16.04. OpenSSL 1.0.1 14 Mar 2012, the same effect on OpenSSL 1.0.2g-fips 1 Mar 2016.
Any thoughts?
I am Trying To Connect a Soap Api by php
ini_set('soap.wsdl_cache_enabled',0);
ini_set('soap.wsdl_cache_ttl',0);
$opts = array(
'ssl' => array('ciphers'=>'RC4-SHA', 'verify_peer'=>false, 'verify_peer_name'=>false)
);
$params = array ('encoding' => 'UTF-8', 'verifypeer' => false, 'verifyhost' => false, 'soap_version' => SOAP_1_1, 'trace' => 1, 'exceptions' => 1, "connection_timeout" => 5, 'stream_context' => stream_context_create($opts) );
$url = "http://x.x.x.x:8080/ws-relay/MessageRelayService?wsdl";
$client =new SoapClient($url,$params);
$result = $client->sendMessageOneToMany(array(
"username" => 'xxxxx',
"password" => 'xxxxx',
"originator" => "50004132311446",
"destination" => $numbers,
"content" => $massage,
));
but it allways got an
SOAP-ERROR: Parsing WSDL: Couldn't load from 'x.x.x.x:8080/ws-relay/MessageRelayService?wsdl";' : failed to load external entity "x.x.x.x:8080/ws-relay/MessageRelayService?wsdl";")
error !
I also Tried to Curl This WSDL but I got
[root#myhost ~]# curl http://x.x.x.x:8080/ws-relay/MessageRelayService?wsdl
curl: (7) Failed to connect to x.x.x.x port 8080: Connection timed out
Error !
so i also tried to curl portquiz.net:8080/ for test and i got timeout again !
is there some rule in firewall that block me to send request to 8080 ports !
how can i unblock it in centos directadmin vps ?
often this happens because that your ip address has been blocked , or there are an issues with the server it self .
for more info about that , libcurl error codes
CURLE_COULDNT_CONNECT (7)
Failed to connect() to host or proxy.
for your command :
curl http://xx.xx.xx.xx:xxxxws-relay/MessageRelayService?wsdl
when executing it in my own pc i got the response normally .
so you will need to use proxy in your SoapClient class
For making an HTTP connection through a proxy server, the options
proxy_host, proxy_port, proxy_login and proxy_password are also
available.
so you will need to add some params to your $params array ass follows :
$params['proxy_host'] = "proxy_ip";
$params['proxy_port'] = "proxy_port";
it's also possible (personally i recommend this) to use procedures libcurl functions or packages built on it.
if you want to use the cli way , so your command may be some thing like this :
curl http://xx.xx.xx.xx:xxxx/ws-relay/MessageRelayService?wsdl -x "ip_address:ip_port"
for socks5 ips
curl http://xx.xx.xx.xx:xxxx/ws-relay/MessageRelayService?wsdl -x "ip_address:ip_port" --socks5
Using Guzzle 6 I am attempting to communicate with an Https endpoint that uses a self-signed certificate.
I am instantiating my Client class as follows:
$authClient = new Client([
'base_uri' => config('app.auth_uri'),
'verify' => false
]);
And attempting a request:
$res = $this->authClient->request('POST', '/auth', [
'form_params' => [
'client_id' => 'XXXXXXXXXXXXXXX',
'username' => 'RSA',
'grant_type' => 'password'
]
]);
Here is the error I get:
cURL error 35: SSL connect error (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
According to the Guzzle docs I should have done enough to bypass the SSL error.
After all that, it turns out my cURL library didn't support the TLS version used by the endpoint. It's a known problem on Centos 6.x servers which my Vagrant box was.
I updated my libcurl with the help of this guide:
Update cURL library on Centos 6
I have simple script connection call using PHP 5.2.10 to a Web service working with SOAP 1.2.
The same PHP installation is able to connect via Web service to another web server working with SOAP 1.1 without issues. In addition, the web services using 1.2 is working fine with another two servers using almost the same hard code.
However, every time I am using SOAP 1.2 on this server with PHP 5.2.10 I got the bellow error if I run the script from a batch file:
Warning: SoapClient::SoapClient(http://www.w3.org/2005/05/xmlmime): failed to open stream: HTTP request failed! HTTP/1.1 401 Authorization Required in C: \NewSimpleConnectionTest.php on line 10
If the script is running via Eclipse PHP with PHP 5.2 on a different computer, it does not have any error so the hard code seems fine, user and password are correct too because it is used on the others servers and on the Eclipse test:
My script is this:
<?php
$_endpoint = "http://server:8080/serverv/ServerAPI";
$_username = "userServer";
$_password = "123ABC!";
try
{
$client = new SoapClient($_endpoint."?WSDL", array('location' => $_endpoint, 'login' => $_username, 'password' => $_password, 'trace' => 1, 'features' => SOAP_USE_XSI_ARRAY_TYPE + SOAP_SINGLE_ELEMENT_ARRAYS, 'soap_version' => SOAP_1_2));
echo 'Connected to Web Services.';
}catch(Exception $e){
echo 'Failure to connect to WebServices.';
}
?>
This is the information in the SOAP and XML phpinfo.
SimpleXML
Simplexml support => enabled
Revision => $Revision: 1.151.2.22.2.46 $
Schema support => enabled
soap
Soap Client => enabled
Soap Server => enabled
Directive => Local Value => Master Value
soap.wsdl_cache => 1 => 1
soap.wsdl_cache_dir => /tmp => /tmp
soap.wsdl_cache_enabled => 1 => 1
soap.wsdl_cache_limit => 5 => 5
soap.wsdl_cache_ttl => 86400 => 86400
Any idea about what is missing or the problem on this PHP version to work with SOAP 1.2 in that server?
Thanks in advance!!
After some hours working around this problem, the solution was changing the version of PHP from 5.2.10 to 5.5.28.
There is some kind of bug on this old version and prevent the correct connection with SOAP 1.2.
I hope this help someone using this old version of PHP.
I'm working under ubuntu 12.04.
I have a classic localhost set up . apache + mysql + php
file_get_contents fail on external url but works well with local file or 'localhost'
file_get_contents('http://google.com');
PHP Warning: file_get_contents(http://google.com): failed to open stream: HTTP request failed!
soapClient fail on external url but works well with local file or 'localhost'
$wsdl = "http://test.webservices.delijn.be/wsrise/services/travel/WEB-INF/wsdl/RiseWebservices.wsdl";
$client = new SoapClient($wsdl,
array(
'trace' => true,
'exceptions' => true,
'soap_version' => SOAP_1_1,
'connection_timeout' => 600,
'compression' => SOAP_COMPRESSION_ACCEPT ,
'encoding'=> 'UTF-8', //ISO-8859-1',
//'cache_wsdl' => WSDL_CACHE_BOTH,
//'host' => "localhost",
//'proxy_host' => "localhost",
//'proxy_port' => 8080,
));
SOAP-ERROR: Parsing WSDL: Couldn't load from
'http://test.webservices.delijn.be/wsrise/services/travel/WEB-INF/wsdl/RiseWebservices.wsdl' : failed to load external entity "http://test.webservices.delijn.be/wsrise/services/travel/WEB-INF/wsdl/RiseWebservices.wsdl"
allow_url_fopen and allow_include_url are on in phpinfo() (set in /etc/php5/apache2/php.ini)
firewall is disabled
apparmor is disabled
suhosin patch is installed and i set suhosin.simulation to true in the php.ini
the code is working well on my production and staging servers
I 'm out of ideas and don't find intresting log or command that can inspect the problem :'(
Thanks for your help !
Ok ! I found a way to make it work.
install de suhosin-php package in order to be able to use the Module suhosin.
set the suhosin.simulation directive to on in /etc/php5/con.d/suhosin.conf
sudo service apache2 restart
Soap calls are still extremely slow, but are working now
Thanks for your help !