[HTTP] Could not connect to host

View: New views
5 Messages — Rating Filter:   Alert me  

[HTTP] Could not connect to host

by Christopher Suter :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have been working with PHP soap for a few weeks now, with a great
deal of success. I am using Apache Axis v1.4, set up as an endpoint on
Mule v1.4.1 ( http://mule.codehaus.org ), which in turn is running as
a service on JBoss AS v4.2.0.

When testing with everything on localhost, I had no problems using the
SoapClient object for a number of services that were exposed via Axis
and Mule. However, when deployed to the live box, I get a connection
error (see subject of this email). The error in more detail is as
follows:


Fatal error:  Uncaught SoapFault exception: [HTTP] Could not connect
to host in /var/www/myproject/login.php:19
Stack trace:
#0 [internal function]: SoapClient->__doRequest(<?xml version="...',
'http://localhos...', '', 1, 0)
#1 [internal function]: SoapClient->__call('login', Array)
#2 /var/www/myproject/login.php(19): SoapClient->login(Array)
#3 /var/www/myproject/login.php(4): doLogin('dummy', 'dummy')
#4 {main} thrown in /var/www/myproject/login.php on line 19




My php code is as follows (the LoginRequest object is just a simple
wrapper class which contains only the fields which I set on it in this
code; it is the reason for the include on line 2):

  1 <?php
  2 include 'myproject.php';
  3
  4 doLogin('dummy','dummy');
  5
  6
  7 function doLogin($username, $password)
  8 {
  9     $client = new
SoapClient("http://myserverIP:8090/actions/AuthenticationUMO?wsdl");
 10
 11     $request = new LoginRequest();
 12
 13     $request->username = $username;
 14     $request->password = $password;
 15     $request->messagetype = "LOGIN";
 16
 17     $loginRequest = array("in0" => $request);
 18
 19     $response = $client->login($loginRequest)->loginReturn;
 20
 21     print (debug_backtrace());
 22
 23     if ($response->ack == 'LOGGED_IN')
 24     {
 25         print("login successful<BR>");
 26     }
 27     else
 28     {
 29         print("login failed...<BR>");
 30     }
 31 }
 32
 33 ?>


The wsdl file corresponding to this service is definitely accessible
(so the SoapClient is not failing to find the wsdl) and if I call
$client->__getFunctions(), it prints out the expected info. I will
spare the details of the actual wsdl file, unless absolutely
necessary.

I am new to pretty much all of these technologies, but have been
working with Mule and Axis for a couple of months now. Please note, I
am NOT a php programmer, I'm just testing my backend code before I
send an API to our frontend developers. This code is just for testing.
I imagine that the problem is something pretty simple, but I have no
clue what it could be. There didn't seem to be anything similar to
this in the mailing list, which tells me that I'm probably making a
stupid error. But any guidance will be hugely appreciated. Thanks in
advance for your time.


--
Christopher Suter

Software Engineer
Escape Media Group
Gainesville, FL

--
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [HTTP] Could not connect to host

by Christian Wenz-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

> Fatal error:  Uncaught SoapFault exception: [HTTP] Could not connect
> to host in /var/www/myproject/login.php:19
> Stack trace:
> #0 [internal function]: SoapClient->__doRequest(<?xml version="...',
> 'http://localhos...', '', 1, 0)

Maybe the server name in the WSDL (localhost?) is not correctly resolved on
the live machine? Just a guess.

Best regards
Christian

--
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [HTTP] Could not connect to host

by ammarmar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dnia 18-08-2007 o 00:37:45 "Christian Wenz" <chw@...>  
napisaƂ(a):

>
> Maybe the server name in the WSDL (localhost?) is not correctly resolved  
> on
> the live machine? Just a guess.
>
> Best regards
> Christian

It cannot be resolved properly - WSDL is processed on client, NOT on  
server. It is only a description file - client extracts web service  
address (location) from WSDL file and tries to connect to it. (Make notice  
that this mechanism can be used e.g. for load balancing - if WSDL file is  
prepared 'on-the fly' you may manipulate where clients will try to  
connect.)

WSDL file should be edited to contain the right address. Alternatively (if  
WSDL can not be edited), the client can overrule WSDL by specifying  
manually service address, e.g.:


$params = array(
        "location" => "http://server.com/here/is/my/web/service/"
        );

$client = new SoapClient($wsdl_address, $params);

(other WSDL features are still apllied, e.g. types and operations  
definitions - this is NOT a 'non-WSDL' mode).

--
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


AW: [HTTP] Could not connect to host

by Christian Wenz-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> WSDL file should be edited to contain the right address.

That's exactly what I wanted to say ;-)

--Christian

--
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[faultstring] => Could not connect to host [faultcode] => HTTP

by ar1014 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have occur the the following error........can u help to avoid this error


[There was an error with your request or the service is unavailable. SoapFault Object ( [messageprotected] => Could not connect to host [stringprivate] => [codeprotected] => 0 [fileprotected] =>.. \soap_text.php [lineprotected] => 11 [traceprivate] => Array ( [0] => Array ( [function] => __doRequest [class] => SoapClient [type] => -> [args] => Array ( [0] => dd95819c3fb81bcb6dfd8 [1] => 10.1.7.142/services/soapLinks/ [2] => [3] => 1 [4] => 0 ) ) [1] => Array ( [function] => __call [class] => SoapClient [type] => -> [args] => Array ( [0] => getStoreLinks [1] => Array ( [0] => Array ( [token] => d95819c3fb81bcb6dfd8 [mid] => 35379 [page] => 1 ) ) ) ) [2] => Array ( [file] =>.. \soap_text.php [line] => 11 [function] => getStoreLinks [class] => SoapClient [type] => -> [args] => Array ( [0] => Array ( [token] => d95819c3fb81bcb6dfd8 [mid] => 35379 [page] => 1 ) ) ) ) [faultstring] => Could not connect to host [faultcode] => HTTP )