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