我需要调用SOAP客户端功能,无需库(的NuSOAP,zendframework,laravel)我只应与PHP自身的工作,因为是另一个proyect一个requiriment对未来更重要的,所以目前我只从这里一个简单的公共Web服务(http://www.service-repository.com/operation/show?operation=GetCitiesByCountry&portType=GlobalWeatherSoap&id=4)的做法,但我需要Help.I尝试调用客户端SOAP的功能,但我recive这个错误:PHP SOAP调用客户端函数
Fatal error: Uncaught SoapFault exception: [soap:Server] System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Data.SqlClient.SqlException: Procedure or function 'getWCity' expects parameter '@CountryName', which was not supplied. at WebServicex.GlobalWeather.GetCitiesByCountry(String CountryName) --- End of inner exception stack trace --- in /Applications/XAMPP/xamppfiles/htdocs/php-soap/soap/Client.php:41 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/php-soap/soap/Client.php(41): SoapClient->__soapCall('GetCitiesByCoun...', Array) #1 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/php-soap/soap/Client.php on line 41
这是我的服务器类:
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();
请帮助我。