Connecting to server getting "Could not connect to host" using PHP and SOAP Ligth (PERL)
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) "
userpass开发者_开发技巧wordTicketObjectTicketCreateNumber
"
[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 Mac/Apache/PHP on the client side.
Thank you in advance!
You have an UTF-8 BOM
in your URL. Use a hex-editor to get it out (and also save all files without BOM)
精彩评论