php实现调用本地客户端,PHP SOAP调用客户端函数

我需要调用soap客户端函数而不使用库(nusoap,zendframework,laravel)我只应该使用php native,因为这是对未来更重要的另一个proyect的要求所以目前我只是使用一个简单的公共Web服务来实践这里(http://www.service-repository.com/operation/show?operation=GetCitiesByCountry&portType=GlobalWeatherSoap&id=4),但我需要Help.I尝试调用客户端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):/ Applications / XAMPP / xamppfiles / htdocs /中抛出的SoapClient - > __ soapCall('GetCitiesByCoun ...',Array)#1第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();

请帮我 .

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值