views:

386

answers:

2

I am very new to web service stuff so please be kind.

I have written a simple POJO class, and deployed it on an axis2 server:

public class Database {

    private Project project;

    public void login(){
     project = new Project();
     project.setDescription("Hello there");
     project.setName("To me");
    }

    public Project getProject(){
     return project;
    }

}

I call the service from a c# client:

localhost.Database db = new WindowsFormsApplication1.localhost.Database();
db.login();

localhost.getProjectResponse pr = new WindowsFormsApplication1.localhost.getProjectResponse();

pr = db.getProject();

When I debug the response is null. At the java end, when I call getProject, the project object is null.

What's happening? How do I preserve the state of project between service calls?

A: 

I'm not sure why @shivaspk left a comment instead of writing an answer, it is quite correct: web service calls (not just axis calls) are meant to be stateless, so although the project object gets created by

db.login();

when you call

db.getProject();

It is being called on a different instance of your Database class that was created by Axis to service the second call.

There is no really good answer to your question, except for you to rethink what you are trying to do. If you need some kind of authentication (via login), then that authentication needs to be part of every web service call.

Michael Sharek
A: 
Tuzo