Spring-WS webservice with MTOM attachment - Hello world test

后端 未结 1 868
情书的邮戳
情书的邮戳 2020-12-30 12:10

I am trying to create a simple Spring webservice which when called returns a file attachment as part of the SOAP response. The Enpoint class is shown below:

And fin

1条回答
  •  旧巷少年郎
    2020-12-30 12:59

    Finally managed to get it to work. The configuration is more or less the same as what i had in my original post. I had to update the configuration file. Here is how my configuration file looks like now.

    
    
    
        
    
        
    
        
            
        
    
        
            
                
                    
                
            
        
    
        
            
                
                    
                    
                
            
            
                
                    
                
            
        
    
        
            
            
        
    
        
            
            
        
    
    

    The changes i added were based on what i read on this article - blog.hpxn.net/2012/06/

    Edit - An example

    Here is an example (based on the spring samples) that returns the attachment in MTOM format. I just tried it and the response is shown below:

       HTTP/1.1 200 OK
    Server: Apache-Coyote/1.1
    Accept: text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
    SOAPAction: ""
    Content-Type: Multipart/Related; start-info="text/xml"; type="application/xop+xml"; boundary="----=_Part_0_17910623.1342789122256"
    Transfer-Encoding: chunked
    Date: Fri, 20 Jul 2012 12:58:42 GMT
    
    ------=_Part_0_17910623.1342789122256
    Content-Type: application/xop+xml; charset=utf-8; type="text/xml"
    
    ?
    ------=_Part_0_17910623.1342789122256
    Content-Type: image/png
    Content-ID: 
    Content-Transfer-Encoding: binary
    
    ‰PNG
    

    Note that i have not configured any Axiom factories. The necessary files are listed below:

    schema.xsd

    
    
    
        
    
        
    
        
    
        
            
                
                
            
        
    
    
    

    spring-ws-servlet.xml

    
    
    
        
    
        
            
        
    
        
    
        
            
        
    
        
            
            
        
    
        
            
            
            
        
    
        
            
        
    
    
    

    web.xml

    
    
        MyCompany HR Holiday Service
    
        
            spring-ws
            org.springframework.ws.transport.http.MessageDispatcherServlet
        
    
        
            spring-ws
            /*
        
    
    
    

    To get the response returned as a SAAJ attachment rather than an MTOM attachment, i have to manually configure the SAAj factories as described in this thread How do I add an attachment to a response payload in Spring-WS?

    0 讨论(0)
提交回复
热议问题