PHP Soap - 无法连接到主机

发布于 2024-12-28 08:16:05 字数 695 浏览 0 评论 0原文

我已经查看了其他解决方案,但找不到类似的问题:

这段代码工作正常:

$wsdlUrl = "https://pilot.prove-uru.co.uk/URUws/uru10a.asmx?wsdl";
$client = new soapclient($wsdlUrl);
print_r($client->__getFunctions());

但是,当我尝试进行方法调用时:

$params = array("AddressLookupUK" => array("address" => array("Postcode" => "NE20 9RF"),
            'AccountName' => "xxxx",
            'Password' => "xxxx"));
$result = $client->AddressLookupUK($params);

我收到错误消息“SoapFault 异常:[HTTP] 无法连接到主持人”。如果我将方法调用更改为

$result = $client->FalseMethod($params);

“函数(“FalseMethod”)不是此服务的有效方法”,这表明它正在按预期连接。有人有任何指示我可以尝试吗?

谢谢

I have looked at other solutions for this but can't find a similar issue:

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);

I get the error message "SoapFault exception: [HTTP] Could not connect to host". If I change the method call to

$result = $client->FalseMethod($params);

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?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

凉世弥音 2025-01-04 08:16:05

这是我使用的代码,希望对某人有帮助:

$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
    }
}

Richard

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
    }
}

Richard

新雨望断虹 2025-01-04 08:16:05

在 WSDL 中,您可以看到端点定义:

<wsdl:service name="URU10a">
    <wsdl:port name="URU10aSoap" binding="tns:URU10aSoap">
        <soap:address location="https://pilot.prove-uru.co.uk:8443/URUws/uru10a.asmx"/>
    </wsdl:port>
    <wsdl:port name="URU10aSoap12" binding="tns:URU10aSoap12">
        <soap12:address location="https://pilot.prove-uru.co.uk:8443/URUws/uru10a.asmx"/>
    </wsdl:port>
</wsdl:service>

我认为您在连接 8443 端口时遇到问题。在我的受限网络中,该服务都不起作用。

编辑

好的,我尝试通过更改 WSDL 使用标准 SSL 端口进行连接。我已从 https://pilot.prove-uru.co 保存了 WSDL .uk/URUws/uru10a.asmx?wsdl 到我的硬盘驱动器,从端点定义中删除端口号并尝试使用soapUI进行连接。 万岁,我收到了回复。

因此,也许他们将服务从 8443 移至 443,而没有更新 WSDL。或者它在两个端口下运行,但由于我们本地网络的限制,您(和我)无法连接 8443。无论如何,我认为您应该联系该服务的提供商并澄清这一点,而不是使用他们的 WSDL 的修补版本。

At the WSDL you see the endpoint deinition:

<wsdl:service name="URU10a">
    <wsdl:port name="URU10aSoap" binding="tns:URU10aSoap">
        <soap:address location="https://pilot.prove-uru.co.uk:8443/URUws/uru10a.asmx"/>
    </wsdl:port>
    <wsdl:port name="URU10aSoap12" binding="tns:URU10aSoap12">
        <soap12:address location="https://pilot.prove-uru.co.uk:8443/URUws/uru10a.asmx"/>
    </wsdl:port>
</wsdl:service>

I think, you have problems connecting the 8443 port. In my restricted network, the service works neither.

EDIT

Ok, I tried to connect using the standard SSL port by changing the WSDL. I have saved the WSDL from https://pilot.prove-uru.co.uk/URUws/uru10a.asmx?wsdl to my hard drive, removed the port numbers from the endpoint definitions and tried to connect using soapUI. Hooray, I got a response.

So maybe they moved the service from 8443 to 443 w/o updating the WSDL. Or it runs under both ports but you (and me) cannot connect the 8443 because of limitations of our local networks. Anyway I think you should contact the provider of this service and clarify this point instead of using a patched version of their WSDL.

江南烟雨〆相思醉 2025-01-04 08:16:05

“函数(“FalseMethod”)不是此服务的有效方法”错误仅是由于 WSDL 检查造成的。 PHP 成功下载了 WSDL,但无法访问其中的 Web 服务。

您必须将 trace 设置为 1 来调试 Soap 调用:

$client = SoapClient("some.wsdl", array('trace' => 1));
$result = $client->SomeFunction();
echo "REQUEST:\n" . $client->__getLastRequest() . "\n";
echo "REQUEST HEADERS:\n" . $client->__getLastRequestHeaders() . "\n";
echo "RESPONSE HEADERS:\n" . $client->__getLastResponseHeaders() . "\n";
echo "Response:\n" . $client->__getLastResponse() . "\n";

另外,请查看 Wsdl 中的 URL 集。

The "Function ("FalseMethod") is not a valid method for this service" error is only due to the WSDL check. PHP successfully downloaded the WSDL, but can't access the Webservices in it.

You have to debug the Soap Call with trace set to 1:

$client = SoapClient("some.wsdl", array('trace' => 1));
$result = $client->SomeFunction();
echo "REQUEST:\n" . $client->__getLastRequest() . "\n";
echo "REQUEST HEADERS:\n" . $client->__getLastRequestHeaders() . "\n";
echo "RESPONSE HEADERS:\n" . $client->__getLastResponseHeaders() . "\n";
echo "Response:\n" . $client->__getLastResponse() . "\n";

Also, have a look at the URL's sets in the Wsdl.

宁愿没拥抱 2025-01-04 08:16:05

我接受了 DerVO 的回答,因为他的指导帮助我解决了问题。端口号并不完全导致问题,但我觉得可能在某种程度上促成了这个问题。

当在soap UI中加载WSDL时,它显示简单和复杂的对象类型没有问题,但在PHP中这导致它失败,即WSDL定义了一组“

理查德

I accepted DerVO's answer as his pointers helped me resolve the issue. The port number was not totally causing the issue but I feel may have been contributing to it in some way.

When loading the WSDL in soap UI it was displaying the simple and complex object types without issue, but within PHP this caused it to fall over i.e. the WSDL defined a set of "

Richard

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文