I am trying to connect to a web service using the ext/soap commands in php5. no matter how simple the client i always get the "Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in..." error. has anyone solved this problem. the client i'm trying now is the example from Zend.

<?php
$client = new
SoapClient(
"http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl"
);

print($client->getQuote("ibm"));
?>

can someone plz help me

dave

    Works fine here (77.4 ATM). Are you behind a firewall or proxy? Was PHP compiled with SOAP support? (I assume so, otherwise the error should be different).

    What type of link are you on, and is what's the value of "default_socket_timeout"?

    Does this help at all?

    <?php
    $client = new SoapClient("http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl", array('exceptions' => 0));
    $result = $client->getQuote("ibm");
    if (is_soap_fault($result)) {
       trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_ERROR);
    } else {
       print($client->getQuote("ibm"));
    }
    ?> 

      The code you submitted needed a slight adjustment for it to work on my box. I'm new to PHP so it's easier to rewrite the code than to make something I don't understand work. Here is the rewrite and the output.

      <?php
      $client = new SoapClient("http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl", array('exceptions' => 0));
      try {
      $result = $client->getQuote("ibm");
      print_r($result);
      }
      catch (SoapFault $result) {
      print_r($result);

      }
      ?>
      -----------------Output---------------------------------------

      X-Powered-By: PHP/5.1.1
      Content-type: text/html

      SoapFault Object
      (
      [message:protected] => Could not connect to host
      [string:private] =>
      [code:protected] => 0
      [file:protected] => PHPDocument5
      [line:protected] => 4
      [trace:private] => Array
      (
      [0] => Array
      (
      [function] => __doRequest
      [class] => SoapClient
      [type] => ->
      [args] => Array
      (
      [0] => <?xml version="1.0" encoding="UTF-8"?>
      <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:xmethods-delayed-quotes" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:getQuote><symbol xsi:type="xsd:string">ibm</symbol></ns1:getQuote></SOAP-ENV:Body></SOAP-ENV:Envelope>

                              [1] => http://64.124.140.30:9090/soap
                              [2] => urn:xmethods-delayed-quotes#getQuote
                              [3] => 1
                              [4] => 0
                          )
      
                  )
      
              [1] => Array
                  (
                      [function] => __call
                      [class] => SoapClient
                      [type] => ->
                      [args] => Array
                          (
                              [0] => getQuote
                              [1] => Array
                                  (
                                      [0] => ibm
                                  )
      
                          )
      
                  )
      
              [2] => Array
                  (
                      [file] => PHPDocument5
                      [line] => 4
                      [function] => getQuote
                      [class] => SoapClient
                      [type] => ->
                      [args] => Array
                          (
                              [0] => ibm
                          )
      
                  )
      
              [3] => Array
                  (
                      [file] => C:\Program Files\Zend\ZendStudioClient-5.1.0\bin\php5\dummy.php
                      [line] => 1
                      [args] => Array
                          (
                              [0] => PHPDocument5
                          )
      
                      [function] => include
                  )
      
          )
      
      [faultstring] => Could not connect to host
      [faultcode] => HTTP

      )

      Sorry it's unformatted

      I'm in a company setting so there may be a proxy, but I’m almost positive that there is a firewall. Could this be my problem? If so what port do I need to request to be open?

      dave

        [1] => http://64.124.140.30:9090/soap

        Looks like 9090. That's what Ethereal shows on my box, too.

        It's definitely part of (the main part of) the problem. It might be possible to write the script to get around the proxy. I'll think on that for a moment....

          Write a Reply...