PHP SOAP 调用客户端函数

PHP SOAP Call Client Functions

我需要在没有库的情况下调用 soap 客户端函数(nusoap,zendframework,laravel)我只应该使用 php native 因为这是对未来更重要的另一个项目的要求所以目前我只是练习一个简单的 public 来自这里的 Web 服务 (http://www.service-repository.com/operation/show?operation=GetCitiesByCountry&portType=GlobalWeatherSoap&id=4 ),但我需要 Help.I 尝试调用客户端 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:

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:

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 元素。