Using Cookie in NuSOAP

25
Nov

Fault

Array ( [faultcode] => soap:Server [faultstring] => Server was unable to process request. ---> Current session has no workflow instance associated with it. Send activation message to start new instance in current session. [detail] => )

Fix for the solution

Description
adds a new Cookie into $this->cookies array
* return: if cookie-set was successful returns true, else false
* access: public
boolean setCookie (string $name, string $value)
* string $name: Cookie Name
* string $value: Cookie Value

When we are using .NET Workflow to continue to do set of activities via webservices, we have to use one cookie to active all webservices, so thet we need to read the cookie from the first webservice header and the set that cookie for the other webservices.

$client->response will show the all response information including cookie.

To set cookie

$client = new soapclient($wsdl);// create new client
$client -> setCookie ("WF_WorkflowInstanceId", "8ea11994-cae7-4abf-8b8f-d223829a7ff0"); // cookie name and id
$mysoapmsg = $client->serializeEnvelope('','',array(),'document', 'literal');
$response = $client->send($mysoapmsg, $soapaction);

Share/Save
10
Average: 10 (1 vote)
Your rating: None

3 comments

23
Aug

OK I undertand, but my

OK

I undertand, but my session in my web services are losting. Can you please set the hole exaple:

crearte the first client to a web service, for exaple: manageSession.asmx/setSession(user,pswd) and then create the other client to get the ... staff fox exaple... manageStaff.asmx/getStaff(id).

I test my web services with aspx pages and localy, they works perfectly but in nusoap they don't

Regards

23
Aug

jejeje I forgot :P ... My

jejeje I forgot :P ...

My name is Jorge Andrés Cañón Sierra
and my email is jacanon7@gmail.com

Regards :)

29
Oct

estimados dejo el siguiente

estimados dejo el siguiente ejemplo básico para mantener la session en el cliente, según lo indicado en los comentarios anteriores.
lo que hace es contar cuantas veces un cliente llama al servicios manteniendo la session.

espero sea de utilidad.

saludos
Mail: miguel_cas77@hotmail.com

<?php
session_start();
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
require_once('./lib/nusoap.php');

$parametros = array(
'valor'=>1,
);

$nombre_cookie=null;
$value_cookie=null;

$client = new nusoap_client('http://192.168.80.6/ws_sesion_test/Service.asmx?wsdl','wsdl');

if(isset($_SESSION['nombre_cookie'])){
$client->setCookie($_SESSION['nombre_cookie'],$_SESSION['value_cookie']); // cookie name and id

}

$result = $client->call('test2', $parametros);

$cookie_ws=$client->getCookies();

foreach($cookie_ws as $value){

$_SESSION['nombre_cookie'] = $value["name"];
$_SESSION['value_cookie'] = $value["value"];

}

var_dump($result);

?>

Post new comment

 
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.

Donate to Us


Activity Stream

Who's online

There are currently 0 users and 16 guests online.
Theme designed by Donny Carette - Powered by Drupal - copyright © 2010