PHP SoapClient Timeout in Different Enviroments - php

I'm working in two differents enviroments, in local machine and production.
I did a soap request using soap ui with local url and request looks great (after 4/5min), that's not happen in production (with production url), after 2min a get a message "connection reset".
$soap = new Zend_Soap_Server ( $url_wsdl,
array (
'soap_version' => SOAP_1_2,
'trace' => true,
'connection_timeout' => 300, "use" => SOAP_ENC_ARRAY,
'encoding' => 'ISO8859-1',
'ssl' => array(
// set some SSL/TLS specific options
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
)
);
I check some timeouts and php.ini and i didn't found not wrong. Anyone have some idea to help me?
Thank you!

Related

Problem with communication with web service

For the past few days I've been trying to connect to web service with soap. This is the configurations that I try to pass to SOAP:
$config['soap_parameters'] = [
'cache_wsdl' => 0,
'trace' => 1,
'stream_context' => stream_context_create(
[
'ssl' => [
'verify_peer' => 0,
'verify_peer_name' => 0,
'allow_self_signed' => 1,
'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT
]
]
),
'login' => 'Username',
'password' => 'Password'
];
$this->configureSoapClient($config, $container);
When I try to sync web service client, I get an error saying Unable to dump a service container if a parameter is an object or a resource. When I've tried to look where's the issue, I've found out that stream_context_create was the problem, because it returns resource and error states, that it doesn't like when you give object or resource. I tried to look for alternative for stream_context_create method, but, unfortunately, seems that there's no alternative for it. Maybe some of you encountered problem like this and have a solution for this? Thank you in advance.

How to create SOAP request in PHP using SOAPClient with authorization?

I have to integrate one soap request in my php laravel .
For that I have some basics information regarding SOAP request i.e
URL
WSDL
HEADERS
now i have tested this soap request in postman it was completely okay
but the problem is when i am trying to do the same on php using SOAP client i am getting the error
here is my code
$options = [
'cache_wsdl' => 0,
'trace' => 1,
'stream_context' => stream_context_create([
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true,
]]),
];
$soapClient = new SoapClient("https://ibluatapig.indusind.com/app/uat/DomesticPayService1", $options);
$headers = new \SoapHeader($nameSpace, 'RequestorCredentials', [
'Content-Type' => 'text/xml',
'SOAPAction' => 'http://tempuri.org/IDomesticPayService/GetAccBalance',
'X-IBM-Client-Secret' => 'secret-key',
'X-IBM-Client-ID' => 'client-id',
]);
$soapClient->__setSoapHeaders($headers);
dd($soapClient);
and the error is
I think my problem is occuring because i am not able to send $namespace for soapHeaders also maybe there is some issue on headers part so please any idea or help why this is happening ??
Thank you !

How could I change the port of target host?

I need send a request using soapclient but I'm not able to change the port of target, if i try to send it addreses like "192.168.1.1:60000" I got the error "Error Fetching http headers".
my code:
$this->client = new SoapClient($wsdlPath, array(
'trace' => 1,
'exceptions' => true,
'ssl' => array(
'verify_peer' => false,
'allow_self_signed' => true
),
'soap_version' => SOAP_1_2
));
$this->client->__setLocation($deviceAddr);
$this->client->__setSoapHeaders($this->soapClientWSSecurityHeader($user,$pass));

Connecting to dev magento soap api v1 with self-signed certificate - wrong version error

I need to connect to Magento SOAP API v1 dev server, which is running over https using self-signed ssl certificate.
Given my soap api url is: https://my-store.com/index.php/api/soap/?wsdl
The traditional way of initiating a soap client like this:
$client = new SoapClient($soap_api_url);
This produces the following error:
SOAP-ERROR: Parsing WSDL: Couldn't load from
'https://my-store.com/index.php/api/soap/?wsdl'
I figured the error must be due to self-signed certificate, so I tried a different approach like this:
$context = stream_context_create([
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
]
]);
$client = new SoapClient(null, [
'location' => $soap_api_url,
'uri' => 'urn:Magento',
'stream_context' => $context
]);
This no longer complains about not being able to load the WSDL, now returns this error:
Wrong Version
I think the problem is with the uri in the connection option; any idea how to tell this code I want to connect to v1 of the magento soap api?
I've fixed it like this:
$context = stream_context_create([
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
]
]);
$client = new SoapClient($soap_api_url, [
'stream_context' => $context
]);

PHP 5.3.6 SoapClient::__doRequest(): SSL: Connection reset by peer

I'm working on consuming a .net web service in php 5.3.6. I'm using SoapClient class to make the connection. It is keep on failing with "SoapClient::__doRequest(): SSL: Connection reset by peer" and "SoapFault Object ( [message:protected] => Error Fetching http headers ".
This is happening only for the Methods/Operations. If i use $response = $objClient->__getFunctions(); and it is working fine and I'm getting the responses with out issue.
$objClient = new SoapClient("http://sample.idws.syndication.kbb.com/3.0/VehicleInformationService.svc?wsdl", array('trace' => 1, 'username' => 'xxxxxxx', 'password' => 'xxxxxxx', 'soap_version' => SOAP_1_2, 'exceptions' => true ));
PHP: php 5.3.6 with ssl soap enabled.
OS: Ubuntu 11.10
i ve been facing a similar issue the past few months.
it turned out afterall that the problem was when i used non-wsdl mode
http://php.net/manual/en/soapclient.soapclient.php
occassionally the remote server wouldn't respond on the request of the location of the wsdl.
initial non-wsdl mode
$soapx = new SoapClient(null,
array(
"trace" => true,
'cache_wsdl' => WSDL_CACHE_NONE,
'location' => 'http://remote_wsdl_url',
'uri' => 'http://necessary_uri',
'use' => SOAP_LITERAL,
'style' => SOAP_DOCUMENT,));
turned to wsdl mode
$soapx = new SoapClient('http://remote_wsdl_url_turned_to_local',
array(
"trace" => true,
'cache_wsdl' => WSDL_CACHE_NONE,));
It seems like there is a problem on the SOAP Server end.
The best online client for debugging SOAP is soapclient
you might give it a try.
I recently came across this due to the same issue. For us the problem was with the SSL protocol being used. We had to force TLS 1.1 and everything started humming along. The key working component for us here is the 'crypto_method'.
$wsdl = 'PATH/TO/WSDL';
$url = 'http://URL_TO_SOAP_SERVICE';
$cert = 'PATH/TO/CLIENT/CERT';
$context = stream_context_create([
'ssl' => [
'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT,
'verify_peer' => true,
'verify_peer_name' => true,
'allow_self_signed' => false,
'cafile' => '/path/to/cafile.selfsigned'
]
]);
$params = [
'location' => $url,
'local_cert' => $cert,
'trace' => true,
'exceptions' => true,
'verifypeer' => true,
'verifyhost' => true,
'allow_self_signed' => false,
'connection_timeout' => 180,
'keep_alive' => false,
'stream_context' => $context
];
$client = new SoapClient($wsdl, $params);

Categories