我正在努力在请求方使用SOAP Ligth和PHP以及我要求信息的服务器上的PERL来获取一些SOAP请求。我之前从未使用过SOAP。
当打印跟踪等时,我尝试连接的URL看起来有线:“http://192.168.1.101/otrs/rpc.pl”。我想这可能是问题的一部分(但我知道什么......)。这是跟踪:
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
以下是生成异常的代码:
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;
}
问题是什么以及如何解决?我应该对URL进行编码吗??
我包含了我认为必要的内容,如果我要添加内容,请告诉我。我在这里可以包含的任何日志中都没有任何内容,我觉得这很奇怪。
我在服务器端使用OpenSUSE / Apache,在客户端使用Mac / Apache / PHP。
提前谢谢!
答案 0 :(得分:3)
您的网址中有UTF-8 BOM
。使用十六进制编辑器将其删除(并保存所有没有 BOM的文件)