Joined: 29 Sep 2015 |
Posts: 1 |
|
|
 |
Posted: Tue Sep 29, 2015 5:32 am |
|
 |
 |
 |
 |
I need to generate a soap request with a user defined variable in PHP.
The request will throw an ID and the response needs to fetch the relevant details associated with the ID.
A portion of the code snippet is given below :
####################CLIENT SCRIPT##########################################
require_once('nusoap.php');
$c = new soapclient('Call to the web service WSDL');
$stockprice = $c->getConsumerInfo('abcd');
########################################################################
'getConsumerInfo' is the name of the web service that is used to generate the soap request and 'abcd' is the variable that is passed as a parameter.
The server script follows :
#########################################################################
Web service function defined :
require('nusoap.php');
function getConsumerInfo($cons_id)
{
$consno = "xxxxxxxx";
return $consno;
}
$server = new soap_server();
$server->configureWSDL('stockserver', 'urn:consno');
$server->register("getConsumerInfo",
array('cons_id' => 'xsd:string'),
array('return' => 'xsd:string'),
'urn:consno',
'urn:consno#getConsumerInfo');
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA)
? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
#########################################################################
|