Forum Moderators: coopster
Anyway... here's the code, which will probably give more of an idea of what i'm after:
SERVER:
// $namespace defined earlier in script
$vars = array();
$server = new soap_server();
$server->debug_flag=false;
$server->configureWSDL('Testing Soap', $namespace);
$server->wsdl->schemaTargetNamespace = $namespace;
$server->register('setValue',
array('inputVar'=>'xsd:string','inputString'=>'xsd:string'),
array('return'=>'xsd:string'),
$namespace);
function setValue($var,$string)
{
global $vars;
$vars[$var]=$string;
return $vars[$var];
}
$server->register('getValue',
array('inputString'=>'xsd:string'),
array('return'=>'xsd:string'),
$namespace);
function getValue($var)
{
global $vars;
return $vars[$var];
}
$server->service($HTTP_RAW_POST_DATA);
CLIENT:
// $wsdl and $namespace defined earlier in script
$client=new soapclient($wsdl, 'wsdl');
$client->useHTTPPersistentConnection();
// NOTE: recurseArray() is a function of my own which just dumps the contents of the input into a list.
$result = $client->call('setValue', array("name","paul"),$namespace);
recurseArray($result);
// returning 'paul', which is what I would expect.
$result = $client->call('getValue', array("name"),$namespace);
recurseArray($result);
// nothing returning, I want it to return 'paul'
Sorry - I'm not real familiar with nusoap, but I think if I were tackling this thing, I would maintain state on the client (website calling the service) side and pass the state to the web service with each call. Take what you get back from the service and "update" your state. You could pass the entire $_SESSION array to your service and it could grab what it needs.
Hope this helps,
Bill
Not sure if this will make sense:
$session = $client->call('getSessionId',array("username","password"),$namespace);
//To get an id from the server and then passing this as the first parameter with every subsequent call...
$result = $client->call('setValue', array($session,"name","paul"),$namespace);
recurseArray($result);
$result = $client->call('getValue', array($session,"name"),$namespace);
recurseArray($result);
I've seen mention that you could pass the id in the SOAP header, but I really don't want to get into the actual XML that's being generated here unless I absolutely have to...