Page 1 of 3 123 LastLast
Results 1 to 10 of 26

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

  1. #1
    Join Date
    Jul 2005
    Posts
    16

    Default 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. #2
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

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

    Spring Web Services Dev Lead
    Please read the FAQ

  3. #3
    Join Date
    Jul 2005
    Posts
    16

    Default

    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.

  4. #4
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

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

    Spring Web Services Dev Lead
    Please read the FAQ

  5. #5
    Join Date
    Oct 2007
    Posts
    9

    Default

    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 at 02:35 AM.

  6. #6
    Join Date
    Jul 2005
    Posts
    16

    Default

    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 at 10:12 AM.

  7. #7
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    Quote 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.
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  8. #8
    Join Date
    Jul 2005
    Posts
    16

    Default

    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.

  9. #9
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    Well, I guess you could use a ThreadLocal...
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  10. #10
    Join Date
    Jul 2005
    Posts
    16

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •