3

i am facing a problem when i call a third-party Soap Web service which accept an attachment in the request. On the WSDL, there is no definition of the related attachment element. Test is OK with SoapUI. I am using the Spring-ws stack (Spring boot version: 2.1.3.RELEASE).

On the spring-ws client code, i've tried to intercept the JAXB request in order to add the attachment file

WebServiceTemplate template = getWebServiceTemplate();

        GetTeamResponse response = (GetTeamResponse) template
                .marshalSendAndReceive(request, new WebServiceMessageCallback() {
            @Override
            public void doWithMessage(WebServiceMessage message) throws IOException, TransformerException {
                FileDataSource fileDataSource = new FileDataSource("~/texte");
                DataHandler dataHandler = new DataHandler(fileDataSource);
                SoapMessage msg = ((SoapMessage)message);
                msg.addAttachment("attachedFile",dataHandler);
               MarshallingUtils.marshal(getMarshaller(), request,msg );

            }
        });

I've got the following error

SAAJ0540: Error during saving a multipart message
Could not write message to OutputStream: Error during saving a multipart message; nested exception is com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Error during saving a multipart message

i notice that there is a lack of spring documentation for this aspect. Thanks in advance for any help

  • Please,see this [https://stackoverflow.com/a/1860685](https://stackoverflow.com/a/1860685), this should help you. – Zakir Hussain Sep 15 '19 at 13:39
  • thanks for your reply, i already checked the mentioned response and it is about lib version incompatibility regards java 6 version..it is not the acse for me as i use spring boot 2 and java8 – ibrahim ben Sep 15 '19 at 14:46
  • you got any solution ? even I am facing a similar issue. – user2719441 Feb 19 '20 at 09:35
  • Hi, unfortunately not using spring-ws. The solution/workaround i implemented was to invoke my soap endpoint directly through http client where i build my request and the soap as a body. it works for me :) – ibrahim ben Feb 20 '20 at 13:17

0 Answers0