Getting UnmarshallingFailureException Expected Items (none) in

Below is the code that I use to call the service:

TaskRequest myrequest = objectFactory.createTaskRequest();
myrequest.setId("12");
JAXBElement jElem = new JAXBElement(
                    new QName("http://service.domain.com/", "taskResponse"),
                    TaskRequest.class, myrequest);

TaskResponse o = (TaskResponse) webServiceTemplate.marshalSendAndReceive(jElem);

I get this exception:

org.springframework.oxm.UnmarshallingFailureException: JAXB throw exception; javax.xml.bind.UnmarshalException nested exception: unexpected element (uri: " http://service.domain.com/ ", local: "taskResponse"). Expected items (none) in org.springframework.oxm.jaxb.Jaxb2Marshaller.convertJaxbException (Jaxb2Marshaller.java:794)

TaskResponse has the following annotations:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "TaskResponse", namespace = "http://message.domain.com/", propOrder = {
    "id",
    "name"
})
public class TaskResponse {...}

These are my WebServiceTemplate settings:

WebServiceTemplate serviceTemplate = new WebServiceTemplate();    
serviceTemplate.setDefaultUri("http://mydomain.com/TaskWebService/taskServ");
serviceTemplate.setMessageFactory(saajSoapMessageFactory());
serviceTemplate.setMessageSender(httpMessageSender());
serviceTemplate.setMarshaller(marshaller());
serviceTemplate.setUnmarshaller(marshaller());

This is my marshaller:

   @Bean
    public Jaxb2Marshaller marshaller() {
        final Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller();

        jaxb2Marshaller.setContextPath("com.domain.message");
        return jaxb2Marshaller;
    }

What could be the reason here?

I am engaged in contract development.

+3
source share
1

, TaskResponse @XmlRootElement , , . , , - ( TaskResponse). SoapUI, ?

0

All Articles