Announcement Announcement Module
Collapse
No announcement yet.
soap with attachments (swa) combined with payload Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • soap with attachments (swa) combined with payload

    Hi,

    To implement Soap with Attachments (SwA) within Spring Web services I am simply implementing MessageEndpoint and then in the invoke(MessageContext) method I cast messageContext.getRequest() to a SoapMessage. From then I can get the attachment.

    However, to also process some message payload (not the attachment part) I am basically writing the implementation of AbstractJDomPayloadEndpoint myself (or one of the other payload endpoints such as AbstractMarshallingPayloadEndpoint).

    It appears to me that there is no way to extend one of the payload endpoint and get the attachment, as I don't seem to have access to the MessageContext.

    It seems a bit odd that I can't get to the MessageContext while utilising one of the payload endpoints. So if I want to use attachments I have to write my own payload endpoint.

    Axis2 has MessageContext.getCurrentMessageContext() that can be called from within a service that marshalls/unmarshalls the payload.

    1. Am I right in my implementation of SwA in Spring Web Services?
    2. Is there a better way to process both the attachment and the message payload?

    Thanks
    Phil

  • #2
    Never mind I've just realised about EndpointInterceptor that I can implement to get the message context and hence the attachments.

    Comment


    • #3
      Hang on, now I get threadsafe issues, because the Endpoint is a singleton and this won't work.
      I simply had code in my interceptor like:

      Code:
      public boolean handleRequest(MessageContext messageContext, Object endpoint) throws Exception {
        MyEndpoint targetEndpoint = (MyEndpoint) endpoint;
        targetEndpoint.setMessageContext(messageContext);
        return true;
      }
      where messageContext is then used within the invokeInternal method of MyEndpoint. But this would not be threadsafe.

      I saw on another thread http://forum.springframework.org/showthread.php?t=45894 someone suggest a request scoped bean, but as I mentioned in a comment on that thread, how does it fit in with http://static.springframework.org/sp...ot-interaction

      Any thoughts?

      Comment


      • #4
        Request-scoped beans are different from prototype beans.
        A new instance of request-scoped beans gets created for each individual http request and lives only for the lifetime of that request. This is similar to using ThreadLocals but has the advantage that Spring takes care of the whole lifecycle of the bean for you.

        For more details on how to use the request scope:
        http://static.springframework.org/sp...scopes-request

        Comment


        • #5
          Thanks Tareq, I was reading the wrong section.

          Comment

          Working...
          X