Web Service Session trouble :(

  • Thread starter Angelos Karantzalis
  • Start date
A

Angelos Karantzalis

hi guys,

I've a couple of web services.

The first one authenticates a user, and saves the principal in the session
object.
The second one authorizes after reading the user data from the session.

Up to now, those two worked wonderfully, and we've had no problems with
them. but now, we're using NUnit to build some tests for the services, and a
C# class as the test. It first makes a call to the login service (which
succeeds) and then to the other service, which fails because there is no
current user principal in the session !

I though it was because the two service stubs were in different namespaces.
But I can't help that, VS.NET won't let you add two web references with the
same namespace name.

Does anybody know what might be going on here ?

Cheers,
Angel
O:]
 
H

Hans Kesting

Angelos said:
hi guys,

I've a couple of web services.

The first one authenticates a user, and saves the principal in the
session object.
The second one authorizes after reading the user data from the
session.

Up to now, those two worked wonderfully, and we've had no problems
with them. but now, we're using NUnit to build some tests for the
services, and a C# class as the test. It first makes a call to the
login service (which succeeds) and then to the other service, which
fails because there is no current user principal in the session !

I though it was because the two service stubs were in different
namespaces. But I can't help that, VS.NET won't let you add two web
references with the same namespace name.

Does anybody know what might be going on here ?

Cheers,
Angel
O:]

Sessions work with cookies. Usually when you call a webservice from
some client, cookies are ignored!
You need to add a place to store those cookies: a CookieContainer.
First create one, then add it to the webservice calls that should work
with the same session.

Hans Kesting
 
B

bruce barker

i assume the web services are in the same vdir, if this is true, then
sessions will be shared - namespace does not matter.

you will also have to add support for the session cookie to your nunit code.
as the unit tests run in seperate domain, you will also need some way to
pass the session id from call1 to call2 (globals will not work)

you might want to have a predefined session id used by unit tests, then the
second caller can call a mocker of the authenication call to get the test
session id.

unless you are writing an acceptance test, i would not use the web service.
I would have unit tests call the modules directly, and supply a mocker for
the web service proxy.

-- bruce (sqlwork.com)



| hi guys,
|
| I've a couple of web services.
|
| The first one authenticates a user, and saves the principal in the session
| object.
| The second one authorizes after reading the user data from the session.
|
| Up to now, those two worked wonderfully, and we've had no problems with
| them. but now, we're using NUnit to build some tests for the services, and
a
| C# class as the test. It first makes a call to the login service (which
| succeeds) and then to the other service, which fails because there is no
| current user principal in the session !
|
| I though it was because the two service stubs were in different
namespaces.
| But I can't help that, VS.NET won't let you add two web references with
the
| same namespace name.
|
| Does anybody know what might be going on here ?
|
| Cheers,
| Angel
| O:]
|
|
 
A

Angelos Karantzalis

Sessions work with cookies. Usually when you call a webservice from
some client, cookies are ignored!
You need to add a place to store those cookies: a CookieContainer.
First create one, then add it to the webservice calls that should work
with the same session.

Hans Kesting

Thanks Hans, that more or less what I'd figured. Could you point me to some
info on how to add a CookieContainer to the web service stubs ?

Cheers,
Angel
O;]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top