JAXBException error while external SOAP web service

421 views Asked by At

The service is made to consume an external soap web service. Despite having set the configs as shown below:

public class Test extends WebServiceGatewaySupport {

  public JAXBElement<Result> callWebService(String url, JAXBElement<Request> request){
  
    return (JAXBElement<Result>) getWebServiceTemplate().marshalSendAndReceive(url, request);
  
  }
}


@Bean
public Jaxb2Marshaller marshaller() {
    
    Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
    marshaller.setContextPath(path);
    return marshaller;
}


@Bean
public Test test(Jaxb2Marshaller jaxb2Marshaller) {
    Test client = new Test();
    client.setDefaultUri(uri);
    client.setMarshaller(jaxb2Marshaller);
    client.setUnmarshaller(jaxb2Marshaller);
    return client;
}

There has been a persistent error reading:

Caused by: jakarta.xml.bind.JAXBException: class javax.xml.bind.JAXBElement nor any of its super class is known to this context.
    at org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:543)
    at org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:444)
    at org.glassfish.jaxb.runtime.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:265)
    at org.glassfish.jaxb.runtime.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:197)
    at org.springframework.oxm.jaxb.Jaxb2Marshaller.marshal(Jaxb2Marshaller.java:712)
    ... 65 more

Mind that the @XmlSeeAlso is present on the objectfactory classes.

The general expectation was that the service is able to reach the third party soap service but it seems to encounter the runtime error when calling the web service with the callWebService( uri, jaxbElement) method.

0

There are 0 answers