php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68855 Soap Could not connect to host
Submitted: 2015-01-19 11:02 UTC Modified: 2015-06-10 07:40 UTC
Votes:36
Avg. Score:4.4 ± 0.9
Reproduced:30 of 32 (93.8%)
Same Version:12 (40.0%)
Same OS:6 (20.0%)
From: lampacz at gmail dot com Assigned:
Status: Open Package: SOAP related
PHP Version: 5.6.4 OS: Debian wheezy
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-01-19 11:02 UTC] lampacz at gmail dot com
Description:
------------
Connecting to SAP https endpoint(https://sap_ip_adress:1802/long_url). After calling soap function (soapclient->function()) getting "Could not connect to host".

PHP version 5.3.3-7+squeeze8 works ok
PHP version 5.4, 5.6.3 doesn't work

Test script:
---------------
$oSC = new SoapClient('sap.wsdl', array(
  'local_cert' => 'sap.crt',
  'location' => 'https://sap_address:8102/sap_url/1.0',
  'user_agent' => 'PHP WS',
  'cache_wsdl' => WSDL_CACHE_NONE,
  'trace' => true,
  'exceptions' => true,
  'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
  'soap_version' => SOAP_1_1
));

$oSC->getInfo();

Expected result:
----------------
Result from getInfo() function

Actual result:
--------------
Could not connect to host

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-09 07:30 UTC] seyferseed at mail dot ru
php 5.6.9 - the same bug
OS - Ubuntu 14.10
 [2015-06-09 07:36 UTC] seyferseed at mail dot ru
Can be fixed with this workaround. Need to add stream context param to SoapClient.

$client = new SoapClient("https://IP:443/sdk/vimService.wsdl",
    array(
        "trace" => 1,
        "location" => "https://IP:443/sdk/",
        'exceptions' => 1,
        "stream_context" => stream_context_create(
            array(
                'ssl' => array(
                    'verify_peer'       => false,
                    'verify_peer_name'  => false,
                )
            )
        )
    ) 
);
 [2015-06-09 08:05 UTC] lampacz at gmail dot com
Of course tried this solution but doesn't work.

$oSC = new SoapClient('sap.wsdl', array(
  'local_cert' => 'sap.crt',
  'location' => 'https://sap_address:8102/sap_url/1.0',
  'user_agent' => 'PHP WS',
  'cache_wsdl' => WSDL_CACHE_NONE,
  'trace' => true,
  'exceptions' => true,
  'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
  'soap_version' => SOAP_1_1,
  'stream_context' => stream_context_create(
    array(
      'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
      )
    )
  )
));
 [2015-06-09 08:12 UTC] seyferseed at mail dot ru
Try to update php to latest 5.6.9 version and perform debian dist-upgrade to latest libs versions.

What does mean parameter 'local_cert' => 'sap.crt'? Try without it.
 [2015-06-09 08:17 UTC] lampacz at gmail dot com
http://php.net/manual/en/soapclient.soapclient.php

For HTTPS client certificate authentication use local_cert and passphrase options

Not possible to use without client https certificate. Certificate is without passphrase
 [2015-06-10 06:39 UTC] seyferseed at mail dot ru
This is my production config for https remote air ticket service, and it is working without any cert, just with pass phrase.

$soapParams = [
            'login'                  => $this->request['user'],
            'password'               => $this->request['password'],
            'trace'                  => true,
            'connection_timeout'     => 10,
            'default_socket_timeout' => 10,
            "exceptions"             => true,
            'soap_version'           => SOAP_1_1,
            'cache_wsdl'             => WSDL_CACHE_NONE,
            'location'               => 'https://link/',
            "stream_context"         => stream_context_create(
                [
                    'ssl' => [
                        'verify_peer'      => false,
                        'verify_peer_name' => false,
                    ]
                ]
            )
        ];
 [2015-06-10 07:40 UTC] lampacz at gmail dot com
This is not my case. I'm using https client certificate (required by server). Your case is ignoring validating https server certificate
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Nov 14 19:01:35 2019 UTC