从apache / php访问iis上的soap


accessing soap on iis from apache / php

我必须在PHP中为托管在Windows/IIS上的web服务制作SoapClient。当我从本地IIS + PHP运行脚本时,它可以工作。当我从本地XAMP或从Apache web服务器运行相同的脚本时,我总是得到相同的错误:

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: ParsingWSDL:无法从'https://online.wings.eu:8080/wsdl/IWingsWeb'加载

<?php
$url = 'https://online.wings.eu:8080/wsdl/IWingsWeb';
$options["connection_timeout"] = 25;
$options["location"] = $url;
$options['trace'] = 1;
$client = new SoapClient($url,$options);
print_r($client->__getFunctions());
?>

在Apache上启用了SOAP和openssl。我还可以访问托管在非windows服务器上的其他服务。

这是我的Apache的问题还是托管SOAP服务器的Windows服务器的问题?

可能无法建立Apache与IIS服务器之间的连接。您应该检查以下内容:

    是否有任何防火墙,反恶意软件程序等,可能会阻止8080(传出,而不是传入)端口从您的Apache服务器?
  • 是否有连接到服务器所需的SSL证书或密码(或两者都有)。如果是,你应该告诉PHP设置合适的头文件。
  • 您可能希望将默认SoapClient替换为直接使用curl的东西。在那里你可以设置一些卷曲参数,并检查是否关于实际错误。

:

class SoapCurlWrapper extends SoapClient {
  protected function callCurl($url, $data, $action) {
     $handle   = curl_init();
     curl_setopt($handle, CURLOPT_URL, $url);
     curl_setopt($handle, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml", 'SOAPAction: "' . $action . '"'));
     curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
     curl_setopt($handle, CURLOPT_SSLVERSION, 3);
     $response = curl_exec($handle);
     if (empty($response)) {
       throw new SoapFault('CURL error: '.curl_error($handle),curl_errno($handle));
     }
     curl_close($handle);
     return $response;
   }
   public function __doRequest($request,$location,$action,$version,$one_way = 0) {
       return $this->callCurl($location, $request, $action);
   }
 }

注意,PHP的SOAP实现不会使用上面的包装器来下载WSDL文件(您必须手动完成),但是您可以将它用于实际的WS调用,并且实际上可能会发现它失败的原因。

您可以像使用任何SoapClient一样使用上述类,例如:

$oWS = new SoapCurlWrapper($location_of_wsdl_file,$parameters);