PHP SoapClient 无法使用 https WS

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3726242/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 10:53:49  来源:igfitidea点击:

PHP SoapClient unable to work with https WS

phpwsdlsoap-client

提问by Erez

i have a problem working with PHP SoapClient with a WS (WSDL) that contains https. my PHP version is 5.2.5. before you ask, yes, i am using PHP's Soap and openSSL extentions.

我在使用包含 https 的 WS (WSDL) 的 PHP SoapClient 时遇到问题。我的 PHP 版本是 5.2.5。在你问之前,是的,我正在使用 PHP 的 Soap 和 openSSL 扩展。

the URL i am trying to reach is: https://id3check.gb.co.uk/gbportalinternational/aspx/id3check_1b.asmx?WSDL

我试图访问的 URL 是:https: //id3check.gb.co.uk/gbportalinternational/aspx/id3check_1b.asmx?WSDL

the code i am using:

我正在使用的代码:

$url = "https://id3check.gb.co.uk/gbportalinternational/aspx/id3check_1b.asmx?WSDL";
$options["connection_timeout"] = 25;  
$options["location"] = $url;

$client = new SoapClient($url,$options);

it fails while constructing the SoapClient, and i get the following error:

它在构建 SoapClient 时失败,我收到以下错误:

Warning: SoapClient::SoapClient(https://id3check.gb.co.uk/gbportalinternational/aspx/id3check_1b.asmx?WSDL): failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\MY-DEV-FOLDER\index.php on line 42 Warning: SoapClient::SoapClient(): I/O warning : failed to load external entity "https://id3check.gb.co.uk/gbportalinternational/aspx/id3check_1b.asmx?WSDL" in C:\MY-DEV-FOLDER\index.php on line 42 Exception thrown - SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://id3check.gb.co.uk/gbportalinternational/aspx/id3check_1b.asmx?WSDL'

警告:SoapClient::SoapClient( https://id3check.gb.co.uk/gbportalinternational/aspx/id3check_1b.asmx?WSDL):无法打开流:连接尝试失败,因为连接方在一段时间后没有正确响应时间,或建立连接失败,因为连接的主机未能响应。在 C:\MY-DEV-FOLDER\index.php 第 42 行警告:SoapClient::SoapClient():I/O 警告:无法加载外部实体“ https://id3check.gb.co.uk/gbportalinternational/ aspx/id3check_1b.asmx?WSDL" in C:\MY-DEV-FOLDER\index.php 第 42 行抛出异常 - SOAP-ERROR: Parsing WSDL: 无法从 ' https://id3check.gb.co.加载。英国/gbportalinternational/aspx/id3check_1b.asmx?WSDL'

can anyone tell me what is the problem?

谁能告诉我是什么问题?

thanks

谢谢

Erez

埃雷兹

回答by Eron Villarreal

You will need to have OpenSSL enabled in PHP to be able to retrieve content over https.

您需要在 PHP 中启用 OpenSSL 才能通过 https 检索内容。

Uncomment this line in php.ini

在 php.ini 中取消注释这一行

extension=php_openssl.dll

Look for the opensslsection in your phpinfo():

openssl在 phpinfo() 中查找该部分:

OpenSSL support => enabled  
OpenSSL Library Version => OpenSSL 0.9.8k 25 Mar 2009
OpenSSL Header Version => OpenSSL 0.9.8k 25 Mar 2009

回答by Dan Soap

I just ran the code you gave and it worked perfectly:

我刚刚运行了您提供的代码,并且运行良好:

<?php
$url = "https://id3check.gb.co.uk/gbportalinternational/aspx/id3check_1b.asmx?WSDL";
$options["connection_timeout"] = 25;
$options["location"] = $url;
$options['trace'] = 1;

$client = new SoapClient($url,$options);

print_r($client->__getFunctions());

results in

结果是

Array
(
    [0] => ID3CheckInitialise_1bResponse ID3CheckInitialise_1b(ID3CheckInitialise_1b $parameters)
    [1] => ID3AddressLookupInitialise_1bResponse ID3AddressLookupInitialise_1b(ID3AddressLookupInitialise_1b $parameters)
    [2] => ID3Check_1bResponse ID3Check_1b(ID3Check_1b $parameters)
    [3] => AddressLookup_1bResponse AddressLookup_1b(AddressLookup_1b $parameters)
)

So maybe you should check if there are any network problems: Is there a firewall blocking the communication from within your server process? (I assume it's IIS?) You may also want to check safe_modesettings, although I doubt this is the problem here.

因此,也许您应该检查是否存在任何网络问题:是否有防火墙阻止了服务器进程内的通信?(我假设它是 IIS?)您可能还想检查safe_mode设置,尽管我怀疑这是这里的问题。