PHP SOAP WSDL - 无法连接到主机

时间:2017-05-18 14:08:48

标签: php web-services soap wsdl

尝试从我拥有的WSDL执行某些函数时出现问题。我使用Basic Auth连接到WSDL,我可以看到所有可用的函数:$functions = $client->__getFunctions();

但后来我尝试执行其中任何一个“[HTTP]无法连接到主机”错误。我的代码在这里:

ini_set('default_socket_timeout', 150);
header('Content-Type: text/plain');
ini_set("soap.wsdl_cache_enabled", "0");

$opts = array(
'ssl' => array('ciphers'=>'RC4-SHA', 'verify_peer'=>false, 'verify_peer_name'=>false)
);

// SOAP 1.2 client
$params = array (
'encoding' => 'UTF-8',
'verifypeer' => false,
'verifyhost' => false,
'soap_version' => SOAP_1_2,
'trace' => 1, 'exceptions' => 1,
"connection_timeout" => 180,
'stream_context' => stream_context_create($opts),
'login' => 'login',
'password' => 'password',
'cache_wsdl' => WSDL_CACHE_NONE
);
$url = "http://address/webservice/wsdl";

try {
$client = new SoapClient($url, $params);
$functions = $client->__getFunctions();
var_dump($functions);


$response = $client->__soapCall('function_name', array());
$client->function_name();

var_dump($response);
} catch (SoapFault $fault) {
echo '<br>'.$fault;
}

有什么想法吗?现在在WSDL文件中我有一个targetNamespace参数,它是“targetNamespace =”http://192.168.0.253:85/webservice/soap“”这可以是一个合法的WSDL文件吗?我的意思是命名空间可以是localhost的ip地址吗?也许这需要在WSDL方面修复?

1 个答案:

答案 0 :(得分:0)

找到解决方案。缺少什么:

    'location' => "http://address/webservice/soap",

参数。