Adil
Adil

Reputation: 2112

PHP Soap "Could not connect to host"

My PHP Soap request fails while connecting to the Reuters TRKD. Unfortunately, it only fails on my local laptop, while the same request works on the server.

My first guess was to check via Wireshark, but it seems after the WSDL file is cached, the request does not get sent to the service endpoint.

And it is only one request that fails, the auth, the rest work fine after authorization. What could be the issue?

php --version

PHP 5.3.10-1ubuntu3 with Suhosin-Patch (cli) (built: Apr 11 2012 17:25:33) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
    with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans

Ubuntu 12.04

UPDATE : I overloaded the SoapClient::__doRequest method to dump the URLs and requests.

__DO REQUEST
$request : <?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://www.reuters.com/ns/2006/05/01/webservices/rkd/Common_1" xmlns:ns2="http://www.reuters.com/ns/2006/05/01/webservices/rkd/TokenManagement_1" xmlns:ns3="http://www.w3.org/2005/08/addressing"><env:Header><ns3:To>https://api.rkd.reuters.com/api/2006/05/01/TokenManagement_1.svc/Anonymous</ns3:To><ns3:Action>http://www.reuters.com/ns/2006/05/01/webservices/rkd/TokenManagement_1/CreateServiceToken_1</ns3:Action></env:Header><env:Body><ns2:CreateServiceToken_Request_1><ns1:ApplicationID>BLAH</ns1:ApplicationID><ns2:Username>BLAH</ns2:Username><ns2:Password>BLAH</ns2:Password></ns2:CreateServiceToken_Request_1></env:Body></env:Envelope>

$location : https://api.rkd.reuters.com/api/TokenManagement/TokenManagement.svc/Anonymous
$action : http://www.reuters.com/ns/2006/05/01/webservices/rkd/TokenManagement_1/CreateServiceToken_1
$version : 2
$one_way : 0
SoapFault exception: [HTTP] Could not connect to host in ..

Looking at other stockoverflow posts i can see that i have ssl installed.

php -i | grep ssl                                                                                                                             1 ↵
Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, sslv3, tls
openssl

Upvotes: 1

Views: 4175

Answers (2)

OldaS
OldaS

Reputation: 181

6 hours attempts.. this works for me: 'stream_context' => stream_context_create(array('ssl' => array('ciphers'=>'RC4-SHA'))) !

`$soap = new SoapClient($wsdl, array(
    'login' => $login,
    'password' => $password,
    'exceptions' => true,
    'stream_context' => stream_context_create(array('ssl' => array('ciphers'=>'RC4-SHA'))),
    'trace' => true
    ));`

info: php.net CURLOPT_SSLVERSION The SSL version (2 or 3) to use. By default PHP will try to determine this itself, although in some cases this must be set manually.

Upvotes: 1

Teson
Teson

Reputation: 6736

try with:

ini_set("soap.wsdl_cache_enabled", 0);

Upvotes: 0

Related Questions