簡體   English   中英

PHP SOAP呼叫客戶端功能

[英]PHP SOAP Call Client Functions

我需要不帶庫(Nusoap,zendframework,laravel)的soap客戶端函數,我只應該使用php native,因為這是對另一個在將來更重要的proyect的要求,因此,目前我僅使用來自在這里( http://www.service-repository.com/operation/show?operation=GetCitiesByCountry&portType=GlobalWeatherSoap&id=4 ),但是我需要幫助。我嘗試調用客戶端soap函數,但是我發現了這個錯誤:

致命錯誤:未捕獲的SoapFault異常:[soap:Server] System.Web.Services.Protocols.SoapException:服務器無法處理請求。 ---> System.Data.SqlClient.SqlException:過程或函數'getWCity'需要未提供的參數'@CountryName'。 在WebServicex.GlobalWeather.GetCitiesByCountry(String CountryName)-內部異常堆棧跟蹤的結尾--在/Applications/XAMPP/xamppfiles/htdocs/php-soap/soap/Client.php:41堆棧跟蹤:#0 / Applications /XAMPP/xamppfiles/htdocs/php-soap/soap/Client.php(41):SoapClient-> __ soapCall('GetCitiesByCoun ...',Array)#1 {main}放在/ Applications / XAMPP / xamppfiles / htdocs /中第41行的php-soap / soap / Client.php

這是我的服務器類:

 class ServerSoap extends SoapServer{ public function __construct(){ $params= array('encoding'=>'UTF-8','soap_version' => SOAP_1_2); $wsdl="http://www.webservicex.com/globalweather.asmx?WSDL"; parent::SoapServer($wsdl,$params); parent::addFunction("GetCitiesByCountry"); } public function fault ($code, $string, $actor = null, $details = null, $name = null) { throw new SoapFault($code, $string, $actor, $details, $name); } } $server = new ServerSoap(); $server->setClass('ServerSoap'); $server->handle(); 

這是我的客戶班:

 class Client extends SoapClient{ public function __construct(){ $wsdl_client="http://localhost:8080/php-soap/soap/ServerSoap.php?wsdl"; $params_client = array( 'trace' => TRUE, 'wsdl'=>TRUE, 'debug'=>TRUE, 'cache_wsdl'=>WSDL_CACHE_BOTH ); parent::__construct($wsdl_client,$params_client); $this->server = new SoapServer($wsdl_client,$params_client); } public function disableClient(){ $old_location = $this->instance->__setLocation(); return $old_location; } } $country="Spain"; $client = new Client(); $client->__soapCall("GetCitiesByCountry", array("CountryName"=>$country)); echo $client->__getLastResponse(); 

請幫我。

遵循提供的wsdl,我認為正確的調用方式是

$client->GetCitiesByCountry([
    'GetCitiesByCountry' => [
        'CountryName' => $country
    ]
];

一件事是GetCitiesByCountry SOAP操作,另一件事是GetCitiesByCountry元素。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM