title: Connecting to server getting "Could not connect to host" using PHP and SOAP Ligth (PERL)
body: <p>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. </p>
  
  <p>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: </p>
  
  <pre><code>Fault message: Could not connect to host
  Fault code: 0
  array(2) {
    [0]=&gt;
    array(4) {
      ["function"]=&gt;
      string(11) "__doRequest"
      ["class"]=&gt;
      string(10) "SoapClient"
      ["type"]=&gt;
      string(2) "-&gt;"
      ["args"]=&gt;
      array(5) {
        [0]=&gt;
        string(645) "
  userpasswordTicketObjectTicketCreateNumber
  "
        [1]=&gt;
        string(35) "http://ï»¿192.168.1.101/otrs/rpc.pl"
        [2]=&gt;
        string(13) "Core#Dispatch"
        [3]=&gt;
        int(1)
        [4]=&gt;
        int(0)
      }
    }
    [1]=&gt;
    array(6) {
      ["file"]=&gt;
      string(54) "/Library/WebServer/Documents/SMICTestProject/index.php"
      ["line"]=&gt;
      int(37)
      ["function"]=&gt;
      string(10) "__soapCall"
      ["class"]=&gt;
      string(10) "SoapClient"
      ["type"]=&gt;
      string(2) "-&gt;"
      ["args"]=&gt;
      array(2) {
        [0]=&gt;
        string(8) "Dispatch"
        [1]=&gt;
        array(4) {
          [0]=&gt;
          string(8) "user"
          [1]=&gt;
          string(11) "password"
          [2]=&gt;
          string(12) "TicketObject"
          [3]=&gt;
          string(18) "TicketCreateNumber"
        }
      }
    }
  }
  Fault trace: // Of some reason this ends up after the actual trace
  Fault line: 37
  </code></pre>
  
  <p>Here is the code that generates the exception: </p>
  
  <pre><code>    try {
  $client = new SoapClient(null, array(
  
      'location'  =&gt; "http://192.168.1.101/otrs/rpc.pl",
      'uri'       =&gt; "Core",
      'trace'     =&gt; 1,
      'login'     =&gt; "user",
      'password'  =&gt; "password",
      'style'     =&gt; SOAP_RPC,
      'use'       =&gt; SOAP_ENCODED
  ));
  
  
  $ticketnumber = $client-&gt;__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-&gt;faultcode}, faultstring: {$fault-&gt;faultstring})", E_USER_ERROR);
  echo "Fault message: ".$fault-&gt;getMessage()."\n";
  echo "Fault code: ".$fault-&gt;getCode()."\n";
  echo "Fault trace: ".var_dump($fault-&gt;getTrace())."\n";
  echo "Fault line: ".$fault-&gt;getLine()."\n";
  echo "Bad SOAP request\n";
  echo "REQUEST:\n".$client-&gt;__getLastRequest()."\n";
  echo "RESPONSE:\n".$client-&gt;__getLastResponse()."\n";
  echo "&lt;/pre&gt;";
  exit;
  }
  </code></pre>
  
  <p>What is the problem and what how can I fix it? Should I encode the URL...?</p>
  
  <p>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. </p>
  
  <p>I'm using OpenSUSE/Apache on the server side and Mac/Apache/PHP on the client side. </p>
  
  <p>Thank you in advance!</p>