0

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

Richard
  • 8,193
  • 28
  • 107
  • 228
  • 1
    please refer this link : https://stackoverflow.com/questions/36018385/com-sun-xml-internal-messaging-saaj-soapexceptionimpl-error-during-saving-a-mul to resolve your issue , it might provide you some insights. – vanshikamalhotra Apr 20 '22 at 12:51
  • @vanshikamalhotra, thank you for your reply. I did read that post earlier, it suggests using Axiom or upgrading Xalan. I have tried adding ` org.apache.ws.commons.axiom.wso2 axiom 1.2.11-wso4v12 ` or ` xerces xercesImpl 2.12.2 ` to my maven dependencies. But this does not help. Any ideas? – Richard Apr 20 '22 at 13:00
  • I have also tried adding the following maven dependencies too: ` org.apache.ws.commons.axiom axiom-api 1.3.0 org.apache.ws.commons.axiom axiom-impl 1.3.0 ` – Richard Apr 20 '22 at 13:03

2 Answers2

0

Adding the following to my pom, fixed my issue.

<!-- https://mvnrepository.com/artifact/net.sf.saxon/saxon-dom -->
<dependency>
    <groupId>net.sf.saxon</groupId>
    <artifactId>saxon-dom</artifactId>
    <version>8.7</version>
</dependency>
Richard
  • 8,193
  • 28
  • 107
  • 228
0

I was facing same error in springboot 3.

Excluding below dependencies helped me.

        <exclusions>
            <exclusion>
                <artifactId>xalan</artifactId>
                <groupId>xalan</groupId>
            </exclusion>
            <exclusion>
                <artifactId>xercesImpl</artifactId>
                <groupId>xerces</groupId>
            </exclusion>
        </exclusions>
Subin Chalil
  • 3,531
  • 2
  • 24
  • 38