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