my dog learned polymorphism*
The moose likes Web Services and the fly likes Web Services problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Web Services problem" Watch "Web Services problem" New topic
Author

Web Services problem

Arvind Purohit
Ranch Hand

Joined: Jun 18, 2010
Posts: 43
Hi All
I have developed a web services. I am getting problem when two different user are trying to access web services concurrently.
In web services two methods are there 1. setInputParameter 2. getUserService

suppose

Time User Operation
10:10 am user1 setInputParameter
10:15 am user2 setInputParameter
10:20 am user1 getUserService


User1 is getting result according to the input parameter seted by user2 not by ( him own )

I am using axis2 1.4 ,eclipse ant build,
My services are goes here
1. User class
2. service class
3. service.xml
3. build file
4. testclass





















Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
You should not store client-specific state in instance variables of the service.
In your example, there is no reason for having two operations. Instead you should have only one that takes an User object as input and returns an User.
Do not use instance variables in the service!

If you must have a stateful web service, then you can have an operation that receives some data, stores it in a database and assigns an unique id to it.
The id is returned to the client and, when invoking subsequent operations on the service that requires access to the data, the client supplies the unique id.
This is, however, still a bad idea, since it will seriously complicate scaling of the service - it is all good and well if you run in one single instance of the service, but imagine the case when you have a layer 4 switch or similar in front of a cluster of servers, each running an instance of the service. In such a scenario, you do not want to use one single database to store all the data, since it will become the bottleneck of the system.
Stateless web services do not need to share any data and can thus be easily scaled.
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
Arvind Purohit
Ranch Hand

Joined: Jun 18, 2010
Posts: 43
Ivan Krizsan wrote:Hi!
You should not store client-specific state in instance variables of the service.
In your example, there is no reason for having two operations. Instead you should have only one that takes an User object as input and returns an User.
Do not use instance variables in the service!

If you must have a stateful web service, then you can have an operation that receives some data, stores it in a database and assigns an unique id to it.
The id is returned to the client and, when invoking subsequent operations on the service that requires access to the data, the client supplies the unique id.
This is, however, still a bad idea, since it will seriously complicate scaling of the service - it is all good and well if you run in one single instance of the service, but imagine the case when you have a layer 4 switch or similar in front of a cluster of servers, each running an instance of the service. In such a scenario, you do not want to use one single database to store all the data, since it will become the bottleneck of the system.
Stateless web services do not need to share any data and can thus be easily scaled.
Best wishes!

Thanks a lot IVAN
I made a web services in which i am not using any instance variable
there is a method which takes arguments and return some thing. It works fine till i return any primitive data type or array of primitive data type, but fails when i try to return my own Object or array of Object . If a am testing through web browser then i am getting correct output

1. service class
2. used class
3. service.aml
4 build.xml
5 test class
6 error






















Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Sorry, I have no experience with Axis so I cannot help you in this case.
Best wishes!
 
Don't get me started about those stupid light bulbs.
 
subject: Web Services problem
 
Similar Threads
struts of ear package has problem in jboss, but the war file runs well in tomcat.
NullPointerException - Alfresco Developer Manual, somecoModuleCore.bootstrapAuthorityCreator
Error using java2wsdl ant task
custom wsdl issue
Axis 2 tutorial - client class compliation error