Only 44 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Accessing the Context from a Web service  RSS feed

 
Miguel Capo
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way of accessing the context with web services? Just like you do with Servlets. Is there an init method or something where you can store objects that you want to reuse in every call to the web service

Thanks
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand your question correctly, there is no overall official API controlling the "web service" environment the way there is for (say) servlets. The standards just talk about messages and the way they are interpreted, hosting apis are left up to toolkit makers.

So - which toolkit are you using?

Bill
 
Miguel Capo
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bill,
I am using AXIS.
What I am after is a way of accessing objects that I can create once only and resuse them in every web service call. I want to load some configuration objects that every call to the WS will need, and I don't want to have to instantiate these objects for every call. I am familiar with servlets and since I am running the WS with TOMCAT I thought that there must be a way of doing this.

Thanks for your quick response
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Axis 1.x seems to support the JAX-RPC interface ServiceLifecycle. If you implement that interface in the Service Endpoint a ServiceLifecycle.init(context:java.lang.Object) will be called. The object passed is actually a javax.xml.rpc.server.ServletEndpointContext. ServletEndpointContext.getServletContext():javax.servlet.ServletContext returns the Servlet Context of the underlying Servlet Container. Axis 2 doesn't support this as it is oriented towards JAX-WS not JAX-RPC.

In JAX-WS you seem to use the @Resource annotation to inject an javax.xml.ws.WebServiceContext into the Web Service class.
[ December 13, 2006: Message edited by: Peer Reynders ]
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The way to retrieve the servlet request object in Axis is described here.

An easier approach (that also doesn't tie you into Axis) might be to store those objects in static fields.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!