2016-12-15 66 views
0

我正在使用SOAP從Linux Centos 6服務器和php客戶端調用web service。在這個星期,我一直無法連接到從soapCall方法主機錯誤。我的代碼如下所示,幾個月後根本沒有改變,但最近大部分時間都出現這個錯誤。我在這裏閱讀了大多數有關問題的答案,但是我的問題還沒有解決。使用香皂時無法連接到主機錯誤

$wsdl="http://x.x.x.x:x/gw/services/Service?wsdl"; 

//Set key as HTTP Header 
$aHTTP['http']['header'] = "key:" .$key ."\r\n"; 

$context = stream_context_create($aHTTP); 

try 
{ 
    $client = new SoapClient($wsdl,array("soap_version" => SOAP_1_2,'trace' => 1,"stream_context" => $context)); 
} 
catch(Exception $e) 
{ 
     return "something";    
} 
//I make $parametrs 
try 
{ 

$res = $client->__soapCall("send",array($parametrs)); 
} 
catch(Exception $e) 
{ 
    print_r($e->getMessage()); //Most of the time it prints could not connect to host 
} 

我將SOAP從_1_1更改爲_1_2,但沒有任何更改。

回答

0

這是我如何調用webservice的SOAP,請注意服務?WSDL應該Service.wsdl

//Initialize values 
$wsdl = "Service.wsdl"; 
$url = "http://x.x.x.x:x/gw/services/"; 
$username = "********"; //add username 
$password = "********"; //add password 


$client = new SoapClient("$url".$wsdl); 
$params = array(
       "username"=>$username, 
       "password"=>$password 
       ); 
$response = $client->UserLogIn($params); //UserLogIn is the function name 

var_dump($response); // to see webservice response 
+0

它工作的時候50%的?WSDL – hodhod

+0

你能訪問您的$ wsdl通過瀏覽器? – Terabyte

+0

是的,我可以通過瀏覽器訪問它,每秒我都可以ping通。 – hodhod

相關問題