web services - PHP SOAP Call Client Functions -
i need call soap client functions without libraries(nusoap , zendframework , laravel) should work php native because requiriment proyect more important on future moment practice simple public web service here( http://www.service-repository.com/operation/show?operation=getcitiesbycountry&porttype=globalweathersoap&id=4 ) , need help.i try call client soap functions recive error:
fatal error: uncaught soapfault exception: [soap:server] system.web.services.protocols.soapexception: server unable process request. ---> system.data.sqlclient.sqlexception: procedure or function 'getwcity' expects parameter '@countryname', not supplied. @ 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
this server 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(); this client 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(); please me.
following wsdl provided, think right way call is
$client->getcitiesbycountry([ 'getcitiesbycountry' => [ 'countryname' => $country ] ]; one thing getcitiesbycountry soap action, , getcitiesbycountry element.
Comments
Post a Comment