How to specify a parameter as part of every web service call?

Posted by LES2 on Stack Overflow See other posts from Stack Overflow or by LES2
Published on 2009-10-15T00:39:38Z Indexed on 2010/05/16 1:50 UTC
Read the original article Hit count: 286

Filed under:
|
|
|
|

Currently, each web service for our application has a user parameter that is added for every method. For example:

@WebService
public interface FooWebService {
   @WebMethod
   public Foo getFoo(@WebParam(name="alwaysHere",header=true,partName="alwaysHere") String user, @WebParam(name="fooId") Long fooId);

 @WebMethod
   public Result deletetFoo(@WebParam(name="alwaysHere",header=true,partName="alwaysHere") String user, @WebParam(name="fooId") Long fooId);

   // ...
}

There could be twenty methods in a service, each with the first parameter as user. And there could be twenty web services.

We don't actually use the 'user' argument in the implementations - in fact, I don't know why it's there - but I wasn't involved in the design, and the person that put it there had a reason (I hope).

Anyway, I'm trying to straighten out this Big Ball of Mud.

I have already come a long way by wrapping the web services by a Spring proxy, which allows me to do some before-and-after processing in an interceptor (before there were at least 20 lines of copy-pasted boiler plate per method).

I'm wondering if there's some kind of "message header" I can apply to the method or package and that can be accessed by some type of handler or something outside of each web service method.

Thanks in advance for the advice, LES

© Stack Overflow or respective owner

Related posts about jax-ws

Related posts about webservices