• Post Reply Bookmark Topic Watch Topic
  • New Topic

attributes in a java web service

 
David Brossard
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I wrote this one-class web service I expose using axis and its standard tools (java2wsdl, wsdl2java) and Tomcat as a container.

My class contains some private attributes e.g.

public class MyClassImpl implements MyClass
{
private String var1 = null;

public void setVar1(String s){var1 = s;}
public String getVar1(){return var1;}
}

No matter how many times I run setVar1, every time I try getVar1, I get null as a value rather than the newly set value. Have I forgotten / missed something about web services?
I added a logger in the setVar1 method in order to see at the server whether the method actually did what I thought it did. And sure enough, it did.

Any help is greatly appreciated,
David.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you setting them in one WS call, and then finding them to be null in the next call? The objects implementing the WS service are allocated for each call, so any values set in one call will be lost the next time around.
 
David Brossard
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes... of course :'( Thanks for pointing it out.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!