0

I have a JAX-WS 2.0 web service implementation, generated from my WSDL.

I need to access the web service operation name in my logical handler implementation.

I used following to get this out, but it returns null always.

context.get(MessageContext.WSDL_OPERATION);

It would be great if any of you could help me to resolve this issue.

My server is WAS 7.0 and development IDE is RAD 8.

Thanks in advance.

Ruwan
  • 1
  • 1
  • Possible duplicate http://stackoverflow.com/q/13535277/1530938 – kolossus Feb 21 '13 at 15:30
  • 1
    @kolossus - not a direct duplicate. Your linked question refers to `SOAPHandler` where this question refers to `LogicalHandler`. A difference is that `LogicalHandler` passes a `LogicalMessageContext` to the `handleMessage` method which has a more limited scope than the `MessageContext` that is passed to `SOAPHandler.handleMessage()`. – majorbanzai Jun 14 '13 at 23:03

3 Answers3

2

If you want SOAPAction Header and it contains the web service name (like mine do) you can use this to print it:

private void inLogger(SOAPMessageContext context){
    HttpServletRequest req = (HttpServletRequest)context.get(MessageContext.SERVLET_REQUEST);
    System.out.println(req.getHeader("SOAPAction"));
}
Xargos
  • 633
  • 8
  • 19
0

You can try this way :

1) Set parameter through the requestContext:

 Map<String, Object> requestCtx = dispatcher.getRequestContext();
 requestCtx.put("operationName", "anyOperation");

2) Check this parameter inside handleMessage in your WS LogicalHandler:

 public boolean handleMessage(LogicalMessageContext messageContext) {
    boolean isCustomOperation = messageContext.containsKey("operationName");
    if (isCustomOperation) {
    // do smth..
    }
    return true;
 }
Dzmitry Hubin
  • 1,091
  • 12
  • 14
0

If your handler is implementing LogicalHandler<LogicalMessageContext> you can do it like this:

((QName)context.get( LogicalMessageContext.WSDL_OPERATION )).getLocalPart();

This will return the name of the operation being called.