Announcement Announcement Module
Collapse
No announcement yet.
How do I extract information from a soap header and pass it to the endpoint Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do I extract information from a soap header and pass it to the endpoint

    I have services defined with implicit soap headers in the WSDL. I need to extract the information from the soap headers in the message and pass some of the information to the endpoint. I can see that an EndpointInterceptor can access the message context, so I can use this to access the header information, but how do I pass along some of the parameters to the endpoint in the message context. Implementations of the endpoint such as AbstractJDomPayloadEndpoint do not have access to the message context that I can see only the payload. I am very familiar with JAX-RPC and know how to do this in a standard J2EE environment, but I am new to Spring web services. Any help or guidance would be appreciated. Thanks.

    -Rick

  • #2
    Well, your endpoint class can implement the MessageEndpoint interface, and then you get access to the whole message context.

    Comment


    • #3
      Are instances of the EndPoint shared across threads or are they created new for each message? Do I need to make the endpoint implementation thread safe? Thanks.

      Comment


      • #4
        Well, it depends on how you define the bean. By default, it has a singleton scope, so it needs to be thread-safe.

        Comment


        • #5
          I didn't understand how to get access to whole soap message omitting Marshalling.
          Code:
          public class MyEndpoint extends AbstractMarshallingPayloadEndpoint implements MessageEndpoint {
          .....
          protected Object invokeInternal(Object obj) throws Exception {
          }
          protected Object invoke(Object obj) throws Exception {
          }
          Code:
          <bean id="payloadMapping"
                          class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
                          <property name="defaultEndpoint" ref="myEndpoint" />
          .....
          Clearly that the method will be never caused.
          Last edited by 13th; Nov 15th, 2007, 02:35 AM.

          Comment


          • #6
            I can add a property for the message context to the endpoint and set that in the inteceptor so that it has a reference to it, but then it is no longer threadsafe. When I try to define my endpoint with prototype scope so that a new instance is created for each request it does not seem to do that. Rather it appears to be using the same instance everytime which is a problem. Is there something special I have to do to get a new instance of my endpoint for each request? I considered defining a thread local variable for the context and setting that so each copy of the endpoint gets the context on it's thread. Would that possibly work?. Thanks.
            Last edited by rjmoran68; Nov 15th, 2007, 10:12 AM.

            Comment


            • #7
              Originally posted by rjmoran68 View Post
              I can add a property for the message context to the endpoint and set that in the inteceptor so that it has a reference to it, but then it is no longer threadsafe.
              A new message context is created for every request, i.e. every thread. So it is thread safe, and you can safely store stuff in your interceptor, and retrieve it in the endpoint.

              Comment


              • #8
                I understand that the message context itself is threadsafe, I was actually referring to the endpoint. The AbstractMarshallingPayloadEndpoint currently has no access to the message context unless I set it as an instance variable from within the inteceptor. This unfortunatley would make the end point no longer threadsafe. My problem here is that I want the convenience of using an AbstractMarshallingPayloadEndpoint (e.g. castor) but I still want access to the message context in a thread safe manor. How can I do this? Thanks.

                Comment


                • #9
                  Well, I guess you could use a ThreadLocal...

                  Comment


                  • #10
                    That is what I did to get around it. I just wasn't sure if I was missing something and there was a better way. Is this something that can be added into the framework to allow access to the message context (similiar to ServiceLifeCycle interface)? Thanks for the help.

                    Comment


                    • #11
                      I'l think about it. One of the possibilities is to do it similar to Spring-MVC's new @Controller and @RequestMapping style. Basically, you would be able to define a WebServiceMessage or MethodContext parameter, and it will be injected by Spring-WS.

                      Comment


                      • #12
                        How to set variables from the interceptor into the endpoint

                        I am trying to solve the same problem mentioned in this thread. From what I have understood so far, if i need to view the SOAP header I would have to define a custom interceptor which would read the message context. This context can then be set into the end point.

                        My question is how do i set a variable in the endpoint from the interceptor. Is it something I would do using the spring configuration files or do I have to programatically do it.

                        Any help on this would be appreciated.

                        Irfan

                        Comment


                        • #13
                          JIRA Created Yet

                          Hi Arjen,

                          Did you happen to create a JIRA for this issue?

                          I think is a common problem - Passing Data from the interceptor to the endpoint and the other way round without loosing the flexibility to use @Endpoint or any other DOM/Marshalling based endpoint.

                          Implementing MessageEndpoint which handles messages individually can lead to a inflated code base for large projects.

                          Using the threadlocal approach is something i can live with but would prefer if the Spring Wiz Team did us a favor

                          Thanks
                          Last edited by Rahul Mishra; Mar 12th, 2008, 12:41 PM.

                          Comment


                          • #14
                            Why not simply inject a "request" scoped bean in an Interceptor and in the Endpoint?
                            The interceptor will extract the infos from the SOAP Header and put them in the bean and then the Endpoint will be able to read them.
                            If you are using a custom Soap Header you can also unmarshal it in the Interceptor to a java Object.

                            Comment


                            • #15
                              How does injecting a request scoped bean into the interceptor and the endpoint work, with regards to this article: http://static.springframework.org/sp...ot-interaction

                              Did I read this wrong or is this saying that you won't necessarily get a new instance of the request scoped bean?

                              Comment

                              Working...
                              X