5

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

hakre
  • 193,403
  • 52
  • 435
  • 836
user1382774
  • 51
  • 1
  • 2
  • same thing happened to me, but it was momentary. The very next call went through just fine. Probably this is from _their_ end. – dhavald Jul 29 '13 at 14:54

3 Answers3

1

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,));
nikolas
  • 723
  • 2
  • 17
  • 37
0

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.

schoash
  • 166
  • 1
  • 6
0

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);
djneely
  • 1,074
  • 13
  • 25