I am using Java 8 with SpringBoot 2.7.0. I have some WSDL files that I use to generate some code using the maven-jaxb2-plugin
plugin. I then create a SOAP client to try invoke the SOAP services:
SOAP Client
public List<SupplierInfo> getAvailableSuppliers() {
ObjectFactory factory = new ObjectFactory();
GetAvailableSuppliersRequest req = new GetAvailableSuppliersRequest();
JAXBElement<GetAvailableSuppliersRequest> request = factory.createGetAvailableSuppliersRequest(req);
GetAvailableSuppliersResponse response = (GetAvailableSuppliersResponse) getWebServiceTemplate().marshalSendAndReceive(request);
return response.getSupplierInfo();
}
Config
@Configuration
public class AvailabilitySOAPClientConfig {
@Bean
public Jaxb2Marshaller marshaller() {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
//marshaller.setContextPath("com.mycompany.restosgi.soap.generated");
marshaller.setPackagesToScan("com.mycompany.restosgi.soap.generated", "com.mycompany.transit._2008a.availability");
return marshaller;
}
@Bean
public AvailabilitySOAPClient availabilitySOAPClient(Jaxb2Marshaller marshaller) {
AvailabilitySOAPClient client = new AvailabilitySOAPClient();
client.setDefaultUri("http://localhost:8080/ws");
client.setMarshaller(marshaller);
client.setUnmarshaller(marshaller);
return client;
}
}
When I call the SOAP client, I get the following error:
Error DOMSource cannot be processed: check that saxon8-dom.jar is on the classpath
SAAJ0539: Unable to get header stream in saveChanges
SAAJ0540: Error during saving a multipart message
org.springframework.ws.soap.saaj.SaajSoapMessageException: 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