How to get JSON response from SOAP Call in PHP
copy soap_server page like (index.php);
-----------------------------------------------------------------------
require_once('../lib/nusoap.php');
$server = new nusoap_server;
$server->configureWSDL('server', 'urn:server');
$server->wsdl->schemaTargetNamespace = 'urn:server';
$server->register('getrequest',
array('name' => 'xsd:string'),
array('return' => 'xsd:string'),
'urn:server',
'urn:server#getrequest');
function getrequest($value,$address)
{
$getval=array('name'=>$value,'address'=>$address);
return json_encode($getval);
}
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>
------------------------------------------------------------------------------------
create soap client page (get json data form soap)getdata.php
----------------------------------------------------------------------------
require_once('../lib/nusoap.php');
$client = new soapclient('http://127.0.0.1/test/nusoap/samples/index.php?wsdl');
$res=$client->__call('getrequest',array('name'=>'bikash','address'=>'teliakan'));
if($client->fault)
{
echo "Fault: <p>Code: {$client->faultcode}<br>";
echo "String: {$client->faultstring}";
}
else
{
echo $res;
}
Gracias me sirvio de mucho
ReplyDeleteHi Payan Thanks for appreciation..:) if you have any other question you can ask by comments
Deletehi,
ReplyDeletei got error when post data to webservices that using json
[faultstring] => Fault occurred while processing.
Hello please post your script what you have done. i can find out your fault. and i ll correct it.
Deletedo replace
Delete$res=$client->__call('getrequest',array('name'=>'bikash','address'=>'teliakan'));
to
$optionarray=array('name'=>'bikash','address'=>'teliakan');
$res=$client->call('getrequest',$optionarray);
gr8. how do you convert a complextype to json? m using this code be its giving me error that it can not serialize it.
ReplyDelete$r=array('name'=>$name,'for'=>$for);
return json_encode($r,JSON_FORCE_OBJECT);
I think you need to put for return json include on top array :-> header('Content-Type: application/json');
DeleteIn addition there are various other will cause pertaining to these kind of models for you to crash as well as operate a lesser amount of proficiently. Some motives may be a result of including an unacceptable adjustments for the command screen. Maybe you mentioned an unacceptable hardness amount. It is usually probable that this softening appliance requires additional salt for you to alleviate the river. How to Fix Pressure Washer Soap Injector (Easy Guide)
ReplyDelete