python - How to send SOAP requests in php -
okay have python server running , i've been using "suds" client side has been surprisingly easy, when tried run similar code in php got confused since beginner it?
from suds.client import client url = 'http://localhost:8080/flightservice?wsdl' client = client(url=url) output = client.service.getflightlist("dxb","ksa") print(output)
is there ease in php or can show me sample code return same result?
considering server receives this:
class input(complextypes.complextype): dpt = str arr = str
and returns list of flights
class flight(complextypes.complextype): id = int dpt = str arr = str price = float date = str tickets = int
this webservice:
@webservice(_params=input,_returns=[flight]) def getflightlist(self, input):
my php segment:
<?php $url = 'http://172.27.130.98:8080/flightservice?wsdl'; $client = new soapclient($url); echo("hello!"); $result = $client->bookflight("dxb","ksa"); $result2 = $client->handle(); echo($result); echo($result2); ?>
php error:
fatal error: uncaught soapfault exception: [http] error fetching http headers in c:\wamp\www\soap\soap.php:6 stack trace: #0 [internal function]: soapclient->__dorequest('<?xml version="...', 'http://172.27.1...', 'http://172.27.1...', 1, 0) #1 c:\wamp\www\soap\soap.php(6): soapclient->__call('getflightlist', array) #2 c:\wamp\www\soap\soap.php(6): soapclient->getflightlist('dxb', 'ksa') #3 {main} thrown in c:\wamp\www\soap\soap.php on line 6
exception info:
soapfault object ( [message:protected] => error fetching http headers [string:exception:private] => [code:protected] => 0 [file:protected] => c:\wamp\www\soap\soap.php [line:protected] => 6 [trace:exception:private] => array ( [0] => array ( [function] => __dorequest [class] => soapclient [type] => -> [args] => array ( [0] => ksa [1] => http://172.27.130.98:8080/flightservice [2] => http://172.27.130.98:8080/flightservice/getflightlist [3] => 1 [4] => 0 ) ) [1] => array ( [file] => c:\wamp\www\soap\soap.php [line] => 6 [function] => __call [class] => soapclient [type] => -> [args] => array ( [0] => getflightlist [1] => array ( [0] => dxb [1] => ksa ) ) ) [2] => array ( [file] => c:\wamp\www\soap\soap.php [line] => 6 [function] => getflightlist [class] => soapclient [type] => -> [args] => array ( [0] => dxb [1] => ksa ) ) ) [previous:exception:private] => [faultstring] => error fetching http headers [faultcode] => http [xdebug_message] => ( ! ) soapfault: error fetching http headers in c:\wamp\www\soap\soap.php on line 6 call stack #timememoryfunctionlocation 10.0006243160{main}( )..\soap.php:0 20.0758264872getflightlist ( )..\soap.php:6 30.0758265336__call ( )..\soap.php:6 )
this solution worked me, instantiated associative array name of variables i'm expecting @ server side used var_dump result of output
<?php $url = 'http://172.27.130.98:8080/flightservice?wsdl'; $client = new soapclient($url); echo("hello!"); $trip["dpt"] = "dxb"; $trip["arr"] = "krt"; try{ $output = $client->getflightlist($trip); } catch(soapfault $e) { print_r($e); } var_dump($output); ?>
Comments
Post a Comment