• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Web Services problem

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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





















 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Arvind Purohit
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
Sorry, I have no experience with Axis so I cannot help you in this case.
Best wishes!
 
My name is Inigo Montoya, you killed my father, prepare to read a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic