Jevgenij Dmitrijev
Jevgenij Dmitrijev

Reputation: 2238

PHP Soap call through https

i have a problem with running methods with SOAP. I'm using Apache and PHP.

this is the PHP code:

$opts = array(
    'ssl' => array('ciphers'=>'RC4-SHA')
);

ini_set('soap.wsdl_cache_enabled',0);
ini_set('soap.wsdl_cache_ttl',0);

$client = new SoapClient('https://host?wsdl', array (
'stream_context' => stream_context_create($opts),
"trace" => 1,
"exceptions" => 0,
"connection_timeout"=>2000));
var_dump($client->__getFunctions());

$params = array ("key" => "value");
$result = $client->availabeFunction($params);
var_dump($result);

The __getFunctions() It returns me all of the available functions.

Then when i'm trying to call the the available function with parameters.

It returns me a strage error message:

public 'faultstring' => string 'Could not connect to host' (length=25)
public 'faultcode' => string 'HTTP' (length=4)

So i presume it is for some reasons are connecting to through the HTTP, but not through HTTPS.

I've looked up the web, and in some cases they are using a local_cert value with a .pem file.

It it neccecity to have it? Or i'm missing something else?

Upvotes: 1

Views: 4836

Answers (2)

Oleg Abrazhaev
Oleg Abrazhaev

Reputation: 2839

It's an openssl library bug.

At first try to disable SSL check by adding this params

"stream_context" => stream_context_create(
    array(
        'ssl' => array(
            'verify_peer'       => false,
            'verify_peer_name'  => false,
        )
    )
)

And next try to not use ?wsdl in location link, try use something like .wsdl

Upvotes: 2

Jevgenij Dmitrijev
Jevgenij Dmitrijev

Reputation: 2238

The solution was much easier as i thoguht it will be:

ini_set('soap.wsdl_cache_enabled',0);
ini_set('soap.wsdl_cache_ttl',0);

$location = 'https://host';

$client = new SoapClient($location . '?wsdl', array (
"trace" => 1,
"exceptions" => 0,
"connection_timeout"=>2000,
"location"=>$location // <- this was the reqiured parameter
));

Everything else is same as before. This beeing cause by WSDL file configuration, that instead of https URL, it has http.

Upvotes: 0

Related Questions