Announcement Announcement Module
No announcement yet.
Attachment Examples Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Attachment Examples

    I am just starting out with Spring-WS and have knocked up a simple service which accepts a message, marshalls the body with Castor and has simple security - all good and easy to get going!

    The next step is adding attachments and after reading the forum posts this seems to be causing trouble for a lot of people. Basically I need to include attachments with my message and was hoping that someone would be able to provide advice and hopefully post some code sample which would prove invaluable to myself and current/future users of Spring-WS.

    I am hoping to test the SWA and MTOM approaches. I am going to look at the mtom sample in the distribution but a swa example would be great if somebody has one they are willing to share.


  • #2
    Spring Web Services Samples

    There is a sample of MTOM that comes packaged with the Spring Web Services download. I am learning how to do this myself and the MTOM example was very helpful(although I couldn't get it to build with maven due to our network). So far I have tried sending attachments using MTOM and by encoding the attachment to base 64 and adding it to the body of the SOAP message. MTOM is definitely much faster. I can't even get the base 64 approach to work with a 40mb file at the moment (socket time out errors in the client).


    • #3
      Soap With Attachments

      The MTOM sample works great, but I would also like to try an SWA example. Are there any tutorials on configuring Spring-WS for SWA? I saw that the SaajSoapMessageFactory is mentioned in the tutorial, but the tutorial doesn't show you how to create endpoints or mappings for this factory. How would this be accomplished?


      • #4

        I have knocked up a SWA example which seems to work but am not sure if it the best/recommended way to go - perhaps someone could comment. I have read various Spring-WS documentation as well as the forums so thanks to everyone for their input so far ....


        I have a webservice which needs to accept XML data and attachments. I would like to use the Spring-WS framework features such as marshalling, I need security and need to be able to process several attachments.


        I created a SAAJ client which builds the message and adds several attachments.

        I am using the PayloadRootAnnotationMethodEndpointMapping to map requests to endpoint.

        I have implemented security using XwsSecurityInterceptor

        I have an "AttachmentInterceptor" which is invoked on each call prior to the endpoint and in this class I get the attachments from the request, validate them and add them to a scoped request parameter for use by the endpoint.

        I have a Castor based marshalling endpoint which processes the request so in my endpoint method, I have access to my domain object (populated by Castor) and the attachments which were extracted by the interceptor.

        Next Steps

        I only got this going last night so it was late and I haven't given the solution a full test bashing yet

        Validation - I assume I can do this in the interceptor ie check number, size and types of attachments.

        InterOp - I need to support Java and .NET clients so full testing is required

        MTOM/Axiom - In the interceptor I (have to?) hardcode the cast of the MessageContext parameter to SaajSoapMessage. Presumably I can also check for different implementations here?


        • #5
          Example code

          Can you please provide the code that you have written for soap attachments. both the server and the client please.



          • #6
            There is the mtom sample, see