[英]accessing soap on iis from apache / php
我必須使用Windows / IIS上托管的Web服務在PHP中創建一個SoapClient。 當我從本地IIS + PHP運行腳本時,它可以工作。 當我從Apache Web服務器的本地XAMP運行相同的腳本時,總是收到相同的錯誤:
致命錯誤:未捕獲的SoapFault異常:[WSDL] SOAP錯誤:解析WSDL:無法從'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());
?>
SOAP和openssl在Apache上啟用。 我還可以訪問非Windows服務器上托管的其他服務。
這是我的Apache的問題,還是托管SOAP服務器的Windows服務器的問題?
可能無法在Apache和IIS服務器之間建立連接。 您應該檢查以下內容:
像這樣:
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);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.