2016-11-02 50 views
2

我想使用PHP的soap客戶端連接到一個web服務,我可以成功地使用Visual Studio,按F5並在本地運行該頁面,以處理工作。使用SOAP和PHP連接到Web服務

只要我上傳完全相同的文件到我的apache web主機,我不斷收到錯誤:「未能加載外部實體」。

這裏是我的代碼與憑據和URL取出...

任何想法?

<?php 
header("Access-Control-Allow-Origin: http://example.com"); 
header("Access-Control-Request-Method: GET,POST"); 

ini_set('display_errors', true); 
ini_set("soap.wsdl_cache_enabled", "0"); 
error_reporting(E_ALL); 


try 
{ 
$soapclient = new SoapClient('http://example.com'); 

$params = array ('SystemID' => 'testID','Username' => 'test', 'Password' => 'test'); 

$response = $soapclient->GetEngineerList($params); 

print_r($response); 

} 
catch(SoapFault $e) 
{ 
    print_r($e); 
} 

回答

2

字符串不讀兩遍,並在單引號

$soapclient = new SoapClient('$url'); 

解析嘗試

$soapclient = new SoapClient($url); 

還...你有$ URL = '';在哪裏?

更新1

請嘗試使用基本身份驗證才能到您的WSDL:

$login = 'bert'; 
$password = 'berts password'; 

$client = new SoapClient(
    'http://' . urlencode($login) . ':' . urlencode($password) . '@www.server.com/path/to/wsdl', 
    array(
    'login' => $login, 
    'password' => $password 
) 
); 
+0

對不起,那裏是$網址是我剛剛編輯的計算器代碼,並刪除我url ...我會編輯我的代碼來糾正它... –

+0

但是...這需要是一個有效的WSDL網址... $ client = new SoapClient(「some.wsdl」); – WEBjuju

+0

有什麼幫助? http://stackoverflow.com/questions/12875409/soap-php-fault-parsing-wsdl-failed-to-load-external-entity – WEBjuju