Announcement Announcement Module
Collapse
No announcement yet.
How to get MessageContext in a Spring3 / JAX-WS implementation? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to get MessageContext in a Spring3 / JAX-WS implementation?

    Hi,

    I apologize if this is not the right forum in which to ask this question, but I believe that the Web Services forum is geared specifically to Spring-WS, which this is not.

    I have a JAX-WS web service that is designed using the Spring 3 IOC container. There is no Spring-WS. I am trying to get access to the MessageContext object in a bean other than the endpoint bean. In order to successfully use Spring IOC, I have added SpringBeanAutowiringSupport.processInjectionBasedO nCurrentContext(this) in a @PostConstruct of my Endpoint class. So far, everything works exactly as expected.

    However, I am running into one issue. I am trying to access the MessageContext object in an aspect, and I have no idea how to accomplish this. I know I can inject a WebServiceContext object into my endpoint class using a @Resource annotation, however, this does not seem to work in any other class.

    Additionally, I have noticed that the CommonAnnotationBeanProcessor intentionally ignores any WebServiceContext types (as per docs) as the JAX-WS framework is supposed to handle it. I have even tried to override the constructor of the class such that it isn't ignored, but that did not make any difference either.

    I am thoroughly stumped at this point. I have tried everything I can think of to get access to the MessageContext from within my Spring classes with no luck.

    Any help/advice would be greatly appreciated.

    Thanks,

    Eric

  • #2
    Originally posted by benze View Post
    Hi,

    I apologize if this is not the right forum in which to ask this question, but I believe that the Web Services forum is geared specifically to Spring-WS, which this is not.

    I have a JAX-WS web service that is designed using the Spring 3 IOC container. There is no Spring-WS. I am trying to get access to the MessageContext object in a bean other than the endpoint bean. In order to successfully use Spring IOC, I have added SpringBeanAutowiringSupport.processInjectionBasedO nCurrentContext(this) in a @PostConstruct of my Endpoint class. So far, everything works exactly as expected.

    However, I am running into one issue. I am trying to access the MessageContext object in an aspect, and I have no idea how to accomplish this. I know I can inject a WebServiceContext object into my endpoint This is an excellent site I love it class using a @Resource annotation, however, this does not seem to work in any other class.

    Additionally, I have noticed that the CommonAnnotationBeanProcessor intentionally ignores any WebServiceContext types (as per docs) as the JAX-WS framework is supposed to handle it. I have even tried to override the constructor of the class such that it isn't ignored, but that did not make any difference either.

    I am thoroughly stumped at this point. I have tried everything I can think of to get access to the MessageContext from within my Spring classes with no luck.

    Any help/advice would be greatly appreciated.

    Thanks,

    Eric





    I also have the same question.
    Last edited by laurabat; Mar 24th, 2012, 12:04 AM.

    Comment


    • #3
      Originally posted by benze View Post

      I am thoroughly stumped at this point. I have tried everything I can think of to get access to the MessageContext from within my Spring classes with no luck.

      Any help/advice would be greatly appreciated.

      Thanks,

      Eric
      I would suggest you have a look at the TransportContext - from that object you can get access to the httpServletRequest e.g. - you can get it using TransportContextHolder.getContext.

      For those using spring-ws, an external developer have created a simple MessageContextHolder that works in the same way as the TransportContextHolder - just storing the MessageContext on a threadlocal instead. He has provided a simple implementation of a MessageContextHolder that you can use to get the MessageContext directly - http://ogrigas.eu/spring/2009/11/acc...-from-anywhere.
      I have used it - and even though he writes that it is for 1.5 - it works fine on 2.0. I think he is referring to the "new" feature in spring-ws 2.0, that allows you to inject the MessageContext or SoapHeader directly in your endpoint simply by specifying it as arguments in the method signature - but that does not help when using aspects.

      So for those reading here that happen to be using spring-ws - the MessageContextHolder implementation still works just fine - but only makese sense if you need the MessageContext in an aspect e.g.

      Cheers
      Flemming
      Last edited by joensson; May 10th, 2012, 01:16 AM. Reason: extra information

      Comment

      Working...
      X