Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在https协议上访问SOAP Web服务引发异常SOAP-ERROR:解析WSDL_Php_Web Services_Soap_Wsdl - Fatal编程技术网

Php 在https协议上访问SOAP Web服务引发异常SOAP-ERROR:解析WSDL

Php 在https协议上访问SOAP Web服务引发异常SOAP-ERROR:解析WSDL,php,web-services,soap,wsdl,Php,Web Services,Soap,Wsdl,我想使用php中的SOAP Web服务。当wsdl路径通过http协议时,我获得了成功,但当我更改为https时,这开始引发以下异常 SOAP-ERROR:分析WSDL:无法从“”加载:加载外部实体失败 此异常在SOAPClient对象创建时引发。我比较了通过http和https获得的wsdl文件,它们都有相同的内容,只是webservice位置路径在一个地方。那么为什么会抛出解析异常呢 我尝试了一些来自互联网的建议,但这些建议对我不起作用: 在php中启用soap、openssl 在SoapC

我想使用php中的SOAP Web服务。当wsdl路径通过http协议时,我获得了成功,但当我更改为https时,这开始引发以下异常

SOAP-ERROR:分析WSDL:无法从“”加载:加载外部实体失败

此异常在SOAPClient对象创建时引发。我比较了通过http和https获得的wsdl文件,它们都有相同的内容,只是webservice位置路径在一个地方。那么为什么会抛出解析异常呢

我尝试了一些来自互联网的建议,但这些建议对我不起作用:

  • 在php中启用soap、openssl
  • 在SoapClient调用的构造函数中传递带有本地证书路径的本地证书作为选项
  • 将wsdl位置传递为登录到openclinica,然后访问webservice
  • 我的要求是通过https协议访问Web服务。当web服务URL路径通过https协议时,是否有其他选项需要传入SoapClient构造函数以创建SoapClient对象? 你能帮我解决上述问题,并提出任何可供参考的文件吗

    更新: 这是我的代码:

    $wsdl = "https://localhost:8443/.../someWsdl.wsdl"; $client = new SoapClient($wsdl, array( 'trace' => 1 ));
    

    我遇到了一个类似的问题,它是由WSDL文件中指定端口81的XML在尝试使用HTTPS(应该是443)时引起的


    我尝试了你的方法,但它对我不起作用,它继续抛出相同的异常。我还验证了wsdl中的位置,它与wsdl的地址匹配。您可以编辑您的问题以包含您用于创建SoapClient的代码吗?@Nitin,您提供的代码没有显示您向SoapClient传递任何SSL、位置或证书选项的位置。谢谢,我的成功关键是
    $options['location]=$wsdl
    
    <wsdl:service name="API">
        <wsdl:port name="APISoap" binding="tns:APISoap">
            <soap:address location="http://example.com:81/api.asmx"/>
        </wsdl:port>
        <wsdl:port name="APISoap12" binding="tns:APISoap12">
            <soap12:address location="http://example.com:81/api.asmx"/>
        </wsdl:port>
    </wsdl:service>
    
    $wsdl = "https://example.com/api.asmx?wsdl";
    
    $SSL['verify_peer_name'] = true;        // Verify the peer name from the WSDL hostname
    $SSL['verify_peer']      = true;        // Verify SSL connection to host
    $SSL['disable_compression'] = true;     // Helps mitigate the CRIME attack vector
    
    $context['ssl'] = $SSL;
    
    $options['location'] = $wsdl;      // Force the endpoint to be HTTPS (WSDL returns endpoint as HTTP at Port 81)
    $options['stream_context'] = stream_context_create($context);
    
    $client = new SoapClient($wsdl, $options);