Loading ...
Sorry, an error occurred while loading the content.

Connecting to server getting “Could not connect to host” using PHP and SOAP Ligt

Expand Messages
  • nic_soft
    Hello, I am struggling to get some SOAP request working using SOAP Ligth and PHP on the requesting side and PERL on the server I am requesting information
    Message 1 of 2 , Aug 3, 2011
    • 0 Attachment
      Hello,

      I am struggling to get some SOAP request working using SOAP Ligth and PHP on the requesting side and PERL on the server I am requesting information from. I have never worked with SOAP before.

      When printing the trace, etc., the URL I am trying to connect to looks wired: "http://192.168.1.101/otrs/rpc.pl". I guess that could be part of the problem (but what do I know...). Here is the trace:



      Fault message: Could not connect to host
      Fault code: 0
      array(2) {
      [0]=>
      array(4) {
      ["function"]=>
      string(11) "__doRequest"
      ["class"]=>
      string(10) "SoapClient"
      ["type"]=>
      string(2) "->"
      ["args"]=>
      array(5) {
      [0]=>
      string(645) "
      userpasswordTicketObjectTicketCreateNumber
      "
      [1]=>
      string(35) "http://192.168.1.101/otrs/rpc.pl"
      [2]=>
      string(13) "Core#Dispatch"
      [3]=>
      int(1)
      [4]=>
      int(0)
      }
      }
      [1]=>
      array(6) {
      ["file"]=>
      string(54) "/Library/WebServer/Documents/SMICTestProject/index.php"
      ["line"]=>
      int(37)
      ["function"]=>
      string(10) "__soapCall"
      ["class"]=>
      string(10) "SoapClient"
      ["type"]=>
      string(2) "->"
      ["args"]=>
      array(2) {
      [0]=>
      string(8) "Dispatch"
      [1]=>
      array(4) {
      [0]=>
      string(8) "user"
      [1]=>
      string(11) "password"
      [2]=>
      string(12) "TicketObject"
      [3]=>
      string(18) "TicketCreateNumber"
      }
      }
      }
      }
      Fault trace: // Of some reason this ends up after the actual trace
      Fault line: 37

      Here is the code that generates the exception:

      try {
      $client = new SoapClient(null, array(

      'location' => "http://192.168.1.101/otrs/rpc.pl",
      'uri' => "Core",
      'trace' => 1,
      'login' => "user",
      'password' => "password",
      'style' => SOAP_RPC,
      'use' => SOAP_ENCODED
      ));


      $ticketnumber = $client->__soapCall("Dispatch", array("user", "password", "TicketObject", "TicketCreateNumber"));
      //Here happens a lot of things, but since this code is never reached I skip including it.

      } catch (SoapFault $fault) {
      //trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);
      echo "Fault message: ".$fault->getMessage()."\n";
      echo "Fault code: ".$fault->getCode()."\n";
      echo "Fault trace: ".var_dump($fault->getTrace())."\n";
      echo "Fault line: ".$fault->getLine()."\n";
      echo "Bad SOAP request\n";
      echo "REQUEST:\n".$client->__getLastRequest()."\n";
      echo "RESPONSE:\n".$client->__getLastResponse()."\n";
      echo "</pre>";
      exit;
      }

      What is the problem and what how can I fix it? Should I encode the URL...?

      I included just what I thought was necessary, please let me know if I should add something. There is absolutely nothing in any logs I can include here, which I find strange itself.

      I'm using OpenSUSE/Apache on the server side and OsX/Apache/PHP on the client side.

      Thank you in advance!
    • Jo Rhett
      This code is PHP, and you ve sent it to the mailing list for the Perl SOAP::Lite module. ... -- Jo Rhett Net Consonance : consonant endings by net
      Message 2 of 2 , Aug 4, 2011
      • 0 Attachment
        This code is PHP, and you've sent it to the mailing list for the Perl SOAP::Lite module.

        On Aug 3, 2011, at 9:26 AM, nic_soft wrote:

        I am struggling to get some SOAP request working using SOAP Ligth and PHP on the requesting side and PERL on the server I am requesting information from. I have never worked with SOAP before.

        When printing the trace, etc., the URL I am trying to connect to looks wired: "http://192.168.1.101/otrs/rpc.pl". I guess that could be part of the problem (but what do I know...). Here is the trace:

        Fault message: Could not connect to host
        Fault code: 0
        array(2) {
        [0]=>
        array(4) {
        ["function"]=>
        string(11) "__doRequest"
        ["class"]=>
        string(10) "SoapClient"
        ["type"]=>
        string(2) "->"
        ["args"]=>
        array(5) {
        [0]=>
        string(645) "
        userpasswordTicketObjectTicketCreateNumber
        "
        [1]=>
        string(35) "http://192.168.1.101/otrs/rpc.pl"
        [2]=>
        string(13) "Core#Dispatch"
        [3]=>
        int(1)
        [4]=>
        int(0)
        }
        }
        [1]=>
        array(6) {
        ["file"]=>
        string(54) "/Library/WebServer/Documents/SMICTestProject/index.php"
        ["line"]=>
        int(37)
        ["function"]=>
        string(10) "__soapCall"
        ["class"]=>
        string(10) "SoapClient"
        ["type"]=>
        string(2) "->"
        ["args"]=>
        array(2) {
        [0]=>
        string(8) "Dispatch"
        [1]=>
        array(4) {
        [0]=>
        string(8) "user"
        [1]=>
        string(11) "password"
        [2]=>
        string(12) "TicketObject"
        [3]=>
        string(18) "TicketCreateNumber"
        }
        }
        }
        }
        Fault trace: // Of some reason this ends up after the actual trace
        Fault line: 37

        Here is the code that generates the exception:

        try {
        $client = new SoapClient(null, array(

        'location' => "http://192.168.1.101/otrs/rpc.pl",
        'uri' => "Core",
        'trace' => 1,
        'login' => "user",
        'password' => "password",
        'style' => SOAP_RPC,
        'use' => SOAP_ENCODED
        ));


        $ticketnumber = $client->__soapCall("Dispatch", array("user", "password", "TicketObject", "TicketCreateNumber"));
        //Here happens a lot of things, but since this code is never reached I skip including it.

        } catch (SoapFault $fault) {
        //trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);
        echo "Fault message: ".$fault->getMessage()."\n";
        echo "Fault code: ".$fault->getCode()."\n";
        echo "Fault trace: ".var_dump($fault->getTrace())."\n";
        echo "Fault line: ".$fault->getLine()."\n";
        echo "Bad SOAP request\n";
        echo "REQUEST:\n".$client->__getLastRequest()."\n";
        echo "RESPONSE:\n".$client->__getLastResponse()."\n";
        echo "</pre>";
        exit;
        }

        What is the problem and what how can I fix it? Should I encode the URL...?

        I included just what I thought was necessary, please let me know if I should add something. There is absolutely nothing in any logs I can include here, which I find strange itself.

        I'm using OpenSUSE/Apache on the server side and OsX/Apache/PHP on the client side.

        Thank you in advance!


        -- 
        Jo Rhett
        Net Consonance : consonant endings by net philanthropy, open source and other randomness

      Your message has been successfully submitted and would be delivered to recipients shortly.