PHP皂 - 无法连接到主机 [英] PHP Soap - Could not connect to host
本文介绍了PHP皂 - 无法连接到主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经看过这个其他的解决方案,但无法找到一个类似的问题:
I have looked at other solutions for this but can't find a similar issue:
code的该位工作确定:
This bit of code works ok:
$wsdlUrl = "https://pilot.prove-uru.co.uk/URUws/uru10a.asmx?wsdl";
$client = new soapclient($wsdlUrl);
print_r($client->__getFunctions());
然而,当我试图让一个方法调用:
However when I try to make a method call:
$params = array("AddressLookupUK" => array("address" => array("Postcode" => "NE20 9RF"),
'AccountName' => "xxxx",
'Password' => "xxxx"));
$result = $client->AddressLookupUK($params);
我收到错误消息的SOAPFault异常:[HTTP]无法连接到主机。如果我的方法调用更改为
I get the error message "SoapFault exception: [HTTP] Could not connect to host". If I change the method call to
$result = $client->FalseMethod($params);
我回来功能(FalseMethod)是不是该服务的有效方法,表明预期它连接。没有任何人有任何指针,我可以试试吗?
I get back "Function ("FalseMethod") is not a valid method for this service" which shows it is connecting as expected. Does anybody have any pointers I can try?
感谢
推荐答案
下面是code我用,希望它可以帮助别人:
Here is the code I used, hope it helps someone:
$wsdlUrl = "address.wsdl";
$client = new soapclient($wsdlUrl);
$params = array('address' => array('Postcode' => $postcode, 'BuildingNo' => $buildingNo),
'AccountName' => 'XXXX',
'Password' => 'XXXX');
$result = $client->AddressLookupUK($params);
$echoText = '';
if (is_null($result->AddressLookupUKResult))
{
//tell the user nothing was returned
}
else
{
//checks to see if the result set contains only one item
if (is_array($result->AddressLookupUKResult->URUAddressFixed))
{
foreach($result->AddressLookupUKResult->URUAddressFixed as $item)
{
//use code like $item->BuildingNo to access the data
}
}
else
{
//if there was there was more than one then access using something like
$result->AddressLookupUKResult->URUAddressFixed->BuildingNo
}
}
理查德
这篇关于PHP皂 - 无法连接到主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文