Unmarshalling Error: unexpected element (uri:url, local:"objectname"). Expected elements are <{}objectname>
Asked Answered
A

6

12

I'm using jaxb2-marshaller to generate classes to communicate with a webservice. Java-classes are generated with use of some wsdl files.

Everything is okay now, but when I'm trying to use some of the generated classes, i got this unmarshalling error, altough I use the generated ObjectFactory classes.

Some of the stack:

org.springframework.ws.soap.client.SoapFaultClientException: Unmarshalling Error: unexpected element (uri:"http://xxxxxxxxx", local:"customer"). Expected elements are <{}customer> 
    at org.springframework.ws.soap.client.core.SoapFaultMessageResolver.resolveFault(SoapFaultMessageResolver.java:38)
    at org.springframework.ws.client.core.WebServiceTemplate.handleFault(WebServiceTemplate.java:826)
    at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:621)
    at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:555)
    at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:390)
    at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:383)
    at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:373)
    at einvoice.service.CustomerService.createCustomer(CustomerService.java:40)
    at einvoice.controller.facturatie.FacturatieOverzichtController.handleRenderRequest(FacturatieOverzichtController.java:36)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

And my class:

@Service
public class CustomerService {

    @Autowired
    private WebServiceTemplate customerDaoTemplate;

    private ObjectFactory customerObjectFactory;

    public CustomerService() {
        customerObjectFactory = new ObjectFactory();    
    }

    public boolean createCustomer(Customer c)
    {
        System.out.println("CREATING CUSTOMER");
        einvoice.proxy.customerdaoservice.Customer customer = customerObjectFactory.createCustomer();
        customer.setConnectionURL("test");
        customer.setUid("testuid");
        customer.setName("KorneelTest");

        Create create = customerObjectFactory.createCreate();
        create.setCustomer(customer);

        try
        {
            customerDaoTemplate.marshalSendAndReceive(customerObjectFactory.createCreate(create));
            return true;
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
            return false;
        }
    }

It's the createCustomer() method that shows this error.

The generated ObjectFactory class:

//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7 
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
// Any modifications to this file will be lost upon recompilation of the source schema. 
// Generated on: 2014.09.12 at 12:04:04 PM CEST 
//


package einvoice.proxy.customerdaoservice;

import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;


/**
 * This object contains factory methods for each 
 * Java content interface and Java element interface 
 * generated in the be.icredit.einvoice.proxy.customerdaoservice package. 
 * <p>An ObjectFactory allows you to programatically 
 * construct new instances of the Java representation 
 * for XML content. The Java representation of XML 
 * content can consist of schema derived interfaces 
 * and classes representing the binding of schema 
 * type definitions, element declarations and model 
 * groups.  Factory methods for each of these are 
 * provided in this class.
 * 
 */
@XmlRegistry
public class ObjectFactory {

    private final static QName _AbstractFilter_QNAME = new QName("http://xxxxxxx/", "abstractFilter");
    private final static QName _Customer_QNAME = new QName("http://xxxxxxx/", "customer");
    private final static QName _FindSingleResponse_QNAME = new QName("http://xxxxxxx/", "findSingleResponse");
    private final static QName _Create_QNAME = new QName("http://xxxxxxx/", "create");
    private final static QName _Find_QNAME = new QName("http://xxxxxxx/", "find");
    private final static QName _CreateResponse_QNAME = new QName("xxxxxxx/", "createResponse");
    private final static QName _FindResponse_QNAME = new QName("http://xxxxxxx/", "findResponse");
    private final static QName _UpdateResponse_QNAME = new QName("http://xxxxxxx/", "updateResponse");
    private final static QName _FindSingle_QNAME = new QName("http://xxxxxxx/", "findSingle");
    private final static QName _CustomerFilter_QNAME = new QName("http://xxxxxxx/", "customerFilter");
    private final static QName _Update_QNAME = new QName("http://xxxxxxx/", "update");
    private final static QName _AbstractEntity_QNAME = new QName("http://xxxxxxx/", "abstractEntity");

    /**
     * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: be.icredit.einvoice.proxy.customerdaoservice
     * 
     */
    public ObjectFactory() {
    }

    /**
     * Create an instance of {@link Update }
     * 
     */
    public Update createUpdate() {
        return new Update();
    }

    /**
     * Create an instance of {@link CustomerFilter }
     * 
     */
    public CustomerFilter createCustomerFilter() {
        return new CustomerFilter();
    }

    /**
     * Create an instance of {@link UpdateResponse }
     * 
     */
    public UpdateResponse createUpdateResponse() {
        return new UpdateResponse();
    }

    /**
     * Create an instance of {@link FindSingle }
     * 
     */
    public FindSingle createFindSingle() {
        return new FindSingle();
    }

    /**
     * Create an instance of {@link FindResponse }
     * 
     */
    public FindResponse createFindResponse() {
        return new FindResponse();
    }

    /**
     * Create an instance of {@link CreateResponse }
     * 
     */
    public CreateResponse createCreateResponse() {
        return new CreateResponse();
    }

    /**
     * Create an instance of {@link FindSingleResponse }
     * 
     */
    public FindSingleResponse createFindSingleResponse() {
        return new FindSingleResponse();
    }

    /**
     * Create an instance of {@link Customer }
     * 
     */
    public Customer createCustomer() {
        return new Customer();
    }

    /**
     * Create an instance of {@link Create }
     * 
     */
    public Create createCreate() {
        return new Create();
    }

    /**
     * Create an instance of {@link Find }
     * 
     */
    public Find createFind() {
        return new Find();
    }

    /**
     * Create an instance of {@link Pager }
     * 
     */
    public Pager createPager() {
        return new Pager();
    }

    /**
     * Create an instance of {@link JAXBElement }{@code <}{@link AbstractFilter }{@code >}}
     * 
     */
    @XmlElementDecl(namespace = "http://xxxxxxx/", name = "abstractFilter")
    public JAXBElement<AbstractFilter> createAbstractFilter(AbstractFilter value) {
        return new JAXBElement<AbstractFilter>(_AbstractFilter_QNAME, AbstractFilter.class, null, value);
    }

    /**
     * Create an instance of {@link JAXBElement }{@code <}{@link Customer }{@code >}}
     * 
     */
    @XmlElementDecl(namespace = "http://xxxxxxx/", name = "customer")
    public JAXBElement<Customer> createCustomer(Customer value) {
        return new JAXBElement<Customer>(_Customer_QNAME, Customer.class, null, value);
    }

    /**
     * Create an instance of {@link JAXBElement }{@code <}{@link FindSingleResponse }{@code >}}
     * 
     */
    @XmlElementDecl(namespace = "http://xxxxxxx/", name = "findSingleResponse")
    public JAXBElement<FindSingleResponse> createFindSingleResponse(FindSingleResponse value) {
        return new JAXBElement<FindSingleResponse>(_FindSingleResponse_QNAME, FindSingleResponse.class, null, value);
    }

    /**
     * Create an instance of {@link JAXBElement }{@code <}{@link Create }{@code >}}
     * 
     */
    @XmlElementDecl(namespace = "http://xxxxxxx/", name = "create")
    public JAXBElement<Create> createCreate(Create value) {
        return new JAXBElement<Create>(_Create_QNAME, Create.class, null, value);
    }

    /**
     * Create an instance of {@link JAXBElement }{@code <}{@link Find }{@code >}}
     * 
     */
    @XmlElementDecl(namespace = "http://xxxxxxx/", name = "find")
    public JAXBElement<Find> createFind(Find value) {
        return new JAXBElement<Find>(_Find_QNAME, Find.class, null, value);
    }

    /**
     * Create an instance of {@link JAXBElement }{@code <}{@link CreateResponse }{@code >}}
     * 
     */
    @XmlElementDecl(namespace = "http://xxxxxxx/", name = "createResponse")
    public JAXBElement<CreateResponse> createCreateResponse(CreateResponse value) {
        return new JAXBElement<CreateResponse>(_CreateResponse_QNAME, CreateResponse.class, null, value);
    }

    /**
     * Create an instance of {@link JAXBElement }{@code <}{@link FindResponse }{@code >}}
     * 
     */
    @XmlElementDecl(namespace = "http://xxxxxxx/", name = "findResponse")
    public JAXBElement<FindResponse> createFindResponse(FindResponse value) {
        return new JAXBElement<FindResponse>(_FindResponse_QNAME, FindResponse.class, null, value);
    }

    /**
     * Create an instance of {@link JAXBElement }{@code <}{@link UpdateResponse }{@code >}}
     * 
     */
    @XmlElementDecl(namespace = "http://xxxxxxx/", name = "updateResponse")
    public JAXBElement<UpdateResponse> createUpdateResponse(UpdateResponse value) {
        return new JAXBElement<UpdateResponse>(_UpdateResponse_QNAME, UpdateResponse.class, null, value);
    }

    /**
     * Create an instance of {@link JAXBElement }{@code <}{@link FindSingle }{@code >}}
     * 
     */
    @XmlElementDecl(namespace = "http://xxxxxxx/", name = "findSingle")
    public JAXBElement<FindSingle> createFindSingle(FindSingle value) {
        return new JAXBElement<FindSingle>(_FindSingle_QNAME, FindSingle.class, null, value);
    }

    /**
     * Create an instance of {@link JAXBElement }{@code <}{@link CustomerFilter }{@code >}}
     * 
     */
    @XmlElementDecl(namespace = "http://xxxxxxx/", name = "customerFilter")
    public JAXBElement<CustomerFilter> createCustomerFilter(CustomerFilter value) {
        return new JAXBElement<CustomerFilter>(_CustomerFilter_QNAME, CustomerFilter.class, null, value);
    }

    /**
     * Create an instance of {@link JAXBElement }{@code <}{@link Update }{@code >}}
     * 
     */
    @XmlElementDecl(namespace = "http://xxxxxxx/", name = "update")
    public JAXBElement<Update> createUpdate(Update value) {
        return new JAXBElement<Update>(_Update_QNAME, Update.class, null, value);
    }

    /**
     * Create an instance of {@link JAXBElement }{@code <}{@link AbstractEntity }{@code >}}
     * 
     */
    @XmlElementDecl(namespace = "http://xxxxxxx/", name = "abstractEntity")
    public JAXBElement<AbstractEntity> createAbstractEntity(AbstractEntity value) {
        return new JAXBElement<AbstractEntity>(_AbstractEntity_QNAME, AbstractEntity.class, null, value);
    }

}

The package-info.java class:

//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7 
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
// Any modifications to this file will be lost upon recompilation of the source schema. 
// Generated on: 2014.09.12 at 03:44:51 PM CEST 
//

@javax.xml.bind.annotation.XmlSchema(namespace = "http://xxxxxxx/")
package einvoice.proxy.customerdaoservice;
Agonizing answered 12/9, 2014 at 9:35 Comment(3)
Can you add spring configuration, Customer and Create classes? ... furthermore why to method marshalSendAndReceive you dont put directly create object?Peculiarity
marshalSendAndReceive converts my 'request' to an understandable format (XML) for the contacted webservice. the create method is used to create an object in the webservice. Added more documentation, no more space for the create class.Agonizing
Nobody? :/. Im really stuck on this.. :sAgonizing
C
12
  • Either your original schema does not have the right target namespace.
  • Or you're somehow missing the package-info.java

Please post your ObjectFactory and package-info.java (must be generated next to the ObjectFactory).

You actually don't have to create your instances via ObjectFactory, normal new constructions work fine. :) ObjectFactory does no magic. It is primarily used by JAXB during unmarshalling.

ps. Please tag the maven-jaxb2-plugin-related questions with the maven-jaxb2-plugin tag - this will get my attention quicker.

Castara answered 12/9, 2014 at 21:43 Comment(7)
The WSDL's I've got are delivered by another company. I will edit my question and provide the generated ObjectFactory and package-info. Many thanks on forehandAgonizing
It's weird. My wsdl's do have the right target namespaces, and I've got the package-info.java class in my project..Agonizing
Hm, everything seems fine on the surface. Please try to make an isolated test case, see if the marshalling in a unit test.Castara
To be honest, I have no experience with creating JUnit test cases, and certainly not In a spring environment. I'm really stuck. I tried to make a 'test'-case by just using this method on startup.Agonizing
Forget the environment, test without any environment. And get to know tests. They help a lot to find out where the error is. If you handle your code as a monolyth, you'll need much more time. Divide it into units and test that they work isolated. Here's a sample unmarshalling test: github.com/highsource/ogc-schemas/blob/master/kml/2.2.0/src/… Tests that the following file unmarshals: github.com/highsource/ogc-schemas/tree/master/kml/2.2.0/src/…Castara
package-info.java was missing in my case. Thanks a lot.Deign
Commenting in case it helps someone: in my case package-info.java was also missing. I thought that copying the generated code from codehaus into the project would be a good idea. Missed out the package-info.java and nothing was working. I generated the code again and added it as a source to the project itself and everything is running smooth.Osmo
N
1

Please use the following annotation

@XmlRootElement(name="Customer")

at the root of the class as shown below. Since JAXb wont create @XmlRootElement annotation automatically, you need to manually put this annotation at the top of the class.

 The generated ObjectFactory class:
This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7 
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
// Any modifications to this file will be lost upon recompilation of the source schema. 
// Generated on: 2014.09.12 at 12:04:04 PM CEST 
//


package einvoice.proxy.customerdaoservice;

import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;


/**
 * This object contains factory methods for each 
 * Java content interface and Java element interface 
 * generated in the be.icredit.einvoice.proxy.customerdaoservice package. 
 * <p>An ObjectFactory allows you to programatically 
 * construct new instances of the Java representation 
 * for XML content. The Java representation of XML 
 * content can consist of schema derived interfaces 
 * and classes representing the binding of schema 
 * type definitions, element declarations and model 
 * groups.  Factory methods for each of these are 
 * provided in this class.
 * 
 */
@XmlRootElement(name="Customer")
@XmlRegistry
public class ObjectFactory {

    private final static QName _AbstractFilter_QNAME = new QName("http://xxxxxxx/", "abstractFilter");
    private final static QName _Customer_QNAME = new QName("http://xxxxxxx/", "customer");
    private final static QName _FindSingleResponse_QNAME = new QName("http://xxxxxxx/", "findSingleResponse");
    private final static QName _Create_QNAME = new QName("http://xxxxxxx/", "create");
    private final static QName _Find_QNAME = new QName("http://xxxxxxx/", "find");
    private final static QName _CreateResponse_QNAME = new QName("xxxxxxx/", "createResponse");
    private final static QName _FindResponse_QNAME = new QName("http://xxxxxxx/", "findResponse");
    private final static QName _UpdateResponse_QNAME = new QName("http://xxxxxxx/", "updateResponse");
    private final static QName _FindSingle_QNAME = new QName("http://xxxxxxx/", "findSingle");
    private final static QName _CustomerFilter_QNAME = new QName("http://xxxxxxx/", "customerFilter");
    private final static QName _Update_QNAME = new QName("http://xxxxxxx/", "update");
    private final static QName _AbstractEntity_QNAME = new QName("http://xxxxxxx/", "abstractEntity");

/**
 * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: be.icredit.einvoice.proxy.customerdaoservice
 * 
 */
public ObjectFactory() {
}

/**
 * Create an instance of {@link Update }
 * 
 */
public Update createUpdate() {
    return new Update();
}

/**
 * Create an instance of {@link CustomerFilter }
 * 
 */
public CustomerFilter createCustomerFilter() {
    return new CustomerFilter();
}

/**
 * Create an instance of {@link UpdateResponse }
 * 
 */
public UpdateResponse createUpdateResponse() {
    return new UpdateResponse();
}

/**
 * Create an instance of {@link FindSingle }
 * 
 */
public FindSingle createFindSingle() {
    return new FindSingle();
}

/**
 * Create an instance of {@link FindResponse }
 * 
 */
public FindResponse createFindResponse() {
    return new FindResponse();
}

/**
 * Create an instance of {@link CreateResponse }
 * 
 */
public CreateResponse createCreateResponse() {
    return new CreateResponse();
}

/**
 * Create an instance of {@link FindSingleResponse }
 * 
 */
public FindSingleResponse createFindSingleResponse() {
    return new FindSingleResponse();
}

/**
 * Create an instance of {@link Customer }
 * 
 */
public Customer createCustomer() {
    return new Customer();
}

/**
 * Create an instance of {@link Create }
 * 
 */
public Create createCreate() {
    return new Create();
}

/**
 * Create an instance of {@link Find }
 * 
 */
public Find createFind() {
    return new Find();
}

/**
 * Create an instance of {@link Pager }
 * 
 */
public Pager createPager() {
    return new Pager();
}

/**
 * Create an instance of {@link JAXBElement }{@code <}{@link AbstractFilter }{@code >}}
 * 
 */
@XmlElementDecl(namespace = "http://xxxxxxx/", name = "abstractFilter")
public JAXBElement<AbstractFilter> createAbstractFilter(AbstractFilter value) {
    return new JAXBElement<AbstractFilter>(_AbstractFilter_QNAME, AbstractFilter.class, null, value);
}

/**
 * Create an instance of {@link JAXBElement }{@code <}{@link Customer }{@code >}}
 * 
 */
@XmlElementDecl(namespace = "http://xxxxxxx/", name = "customer")
public JAXBElement<Customer> createCustomer(Customer value) {
    return new JAXBElement<Customer>(_Customer_QNAME, Customer.class, null, value);
}

/**
 * Create an instance of {@link JAXBElement }{@code <}{@link FindSingleResponse }{@code >}}
 * 
 */
@XmlElementDecl(namespace = "http://xxxxxxx/", name = "findSingleResponse")
public JAXBElement<FindSingleResponse> createFindSingleResponse(FindSingleResponse value) {
    return new JAXBElement<FindSingleResponse>(_FindSingleResponse_QNAME, FindSingleResponse.class, null, value);
}

/**
 * Create an instance of {@link JAXBElement }{@code <}{@link Create }{@code >}}
 * 
 */
@XmlElementDecl(namespace = "http://xxxxxxx/", name = "create")
public JAXBElement<Create> createCreate(Create value) {
    return new JAXBElement<Create>(_Create_QNAME, Create.class, null, value);
}

/**
 * Create an instance of {@link JAXBElement }{@code <}{@link Find }{@code >}}
 * 
 */
@XmlElementDecl(namespace = "http://xxxxxxx/", name = "find")
public JAXBElement<Find> createFind(Find value) {
    return new JAXBElement<Find>(_Find_QNAME, Find.class, null, value);
}

/**
 * Create an instance of {@link JAXBElement }{@code <}{@link CreateResponse }{@code >}}
 * 
 */
@XmlElementDecl(namespace = "http://xxxxxxx/", name = "createResponse")
public JAXBElement<CreateResponse> createCreateResponse(CreateResponse value) {
    return new JAXBElement<CreateResponse>(_CreateResponse_QNAME, CreateResponse.class, null, value);
}

/**
 * Create an instance of {@link JAXBElement }{@code <}{@link FindResponse }{@code >}}
 * 
 */
@XmlElementDecl(namespace = "http://xxxxxxx/", name = "findResponse")
public JAXBElement<FindResponse> createFindResponse(FindResponse value) {
    return new JAXBElement<FindResponse>(_FindResponse_QNAME, FindResponse.class, null, value);
}

/**
 * Create an instance of {@link JAXBElement }{@code <}{@link UpdateResponse }{@code >}}
 * 
 */
@XmlElementDecl(namespace = "http://xxxxxxx/", name = "updateResponse")
public JAXBElement<UpdateResponse> createUpdateResponse(UpdateResponse value) {
    return new JAXBElement<UpdateResponse>(_UpdateResponse_QNAME, UpdateResponse.class, null, value);
}

/**
 * Create an instance of {@link JAXBElement }{@code <}{@link FindSingle }{@code >}}
 * 
 */
@XmlElementDecl(namespace = "http://xxxxxxx/", name = "findSingle")
public JAXBElement<FindSingle> createFindSingle(FindSingle value) {
    return new JAXBElement<FindSingle>(_FindSingle_QNAME, FindSingle.class, null, value);
}

/**
 * Create an instance of {@link JAXBElement }{@code <}{@link CustomerFilter }{@code >}}
 * 
 */
@XmlElementDecl(namespace = "http://xxxxxxx/", name = "customerFilter")
public JAXBElement<CustomerFilter> createCustomerFilter(CustomerFilter value) {
    return new JAXBElement<CustomerFilter>(_CustomerFilter_QNAME, CustomerFilter.class, null, value);
}

/**
 * Create an instance of {@link JAXBElement }{@code <}{@link Update }{@code >}}
 * 
 */
@XmlElementDecl(namespace = "http://xxxxxxx/", name = "update")
public JAXBElement<Update> createUpdate(Update value) {
    return new JAXBElement<Update>(_Update_QNAME, Update.class, null, value);
}

/**
 * Create an instance of {@link JAXBElement }{@code <}{@link AbstractEntity }{@code >}}
 * 
 */
@XmlElementDecl(namespace = "http://xxxxxxx/", name = "abstractEntity")
public JAXBElement<AbstractEntity> createAbstractEntity(AbstractEntity value) {
    return new JAXBElement<AbstractEntity>(_AbstractEntity_QNAME, AbstractEntity.class, null, value);
}

}

Needlework answered 1/2, 2016 at 4:54 Comment(0)
M
1

If you have more than 1 module in your project check for duplicate Class names or directory names.

I was getting the same error and I was able to resolve it by changing the package names in my project.

I had two modules in my project with identical directory structures module/src/main/java/com/example/directory/path

We had two different endpoints and 2 different WSDLs, but both were from the same client. When we auto-generated the POJO classes from the WSDLs it created the file structure for us. I noticed that the namespace generated in the XML was using the same namespace for XML generated in both modules, when they were supposed to be different (hence the stacktrace).

All I did to solve the problem was change the directory names to be more specific for each module.

Marketplace answered 16/1, 2018 at 18:43 Comment(0)
T
1

If SAXParserFactory is being used and than while doing the unmarshalling getting the error. The solution might lie to aware SAXParserFactory about the namespace.

SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
Transmitter answered 20/6, 2022 at 17:17 Comment(0)
A
0

I think I found the problem.

I was using the 0.9.0 version of the maven-jaxb2-plugin. This version gave me that strange exception! I reverted to the 0.8.3 version of maven-jaxbe2-plugin, this version throws a 404 error:

08:56:45,212 ERROR [DispatcherPortlet:572] Could not complete request
org.springframework.ws.client.WebServiceTransportException: Not Found [404]
    at org.springframework.ws.client.core.WebServiceTemplate.handleError(WebServiceTemplate.java:695)
    at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:606)
    at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:555)
    at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:390)
    at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:383)
    at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:373)
    at be.icredit.einvoice.service.CustomerService.createCustomer(CustomerService.java:43)
    at be.icredit.einvoice.controller.facturatie.FacturatieOverzichtController.handleRenderRequest(FacturatieOverzichtController.java:36)
Agonizing answered 15/9, 2014 at 9:20 Comment(0)
B
0

This trace is generated because of the names of de request and response message are not de same in the WSDL and de java class:

Reponse Message:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "acceptMessageResponse", propOrder = {
    "acceptMessageReturn"
})
public class AcceptMessageResponse {

    @XmlElement(required = true)
    protected String acceptMessageReturn;

    public String getAcceptMessageReturn() {
        return acceptMessageReturn;
    }
    public void setAcceptMessageReturn(String value) {
        this.acceptMessageReturn = value;
    }
}

Accept Message:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "acceptMessage", propOrder = {
    "in0"
})
public class AcceptMessage {

    @XmlElement(required = true)
    protected String in0;

    public String getIn0() {
        return in0;
    }
    public void setIn0(String value) {
        this.in0 = value;
    }
}

In this example the WSDL must define: 1.

<?xml version='1.0' encoding='UTF-8'?>
<wsdl:definitions name="PORX_IN02016001SACYL"
    targetNamespace="http://components.mule.server.mirth.webreach.com"
    xmlns:ns1="http://cxf.apache.org/bindings/xformat" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:tns="http://components.mule.server.mirth.webreach.com"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <wsdl:types>
        <xs:schema elementFormDefault="qualified"
            targetNamespace="http://components.mule.server.mirth.webreach.com"
            version="1.0" xmlns:tns="http://components.mule.server.mirth.webreach.com"
            xmlns:xs="http://www.w3.org/2001/XMLSchema">
            <xs:element name="acceptMessage">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element form="unqualified" name="in0" type="xs:string" />
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="acceptMessageResponse" nillable="true"
                type="xs:anyType" />
            <xs:complexType name="acceptMessageResponse">
                <xs:sequence />
            </xs:complexType>
        </xs:schema>
    </wsdl:types>
    <wsdl:message name="acceptMessage">
        <wsdl:part element="tns:acceptMessage" name="parameters">
        </wsdl:part>
    </wsdl:message>
    <wsdl:message name="acceptMessageResponse">
        <wsdl:part element="tns:acceptMessageResponse" name="parameters">
        </wsdl:part>
    </wsdl:message>
    <wsdl:portType name="PORX_IN02016001SACYL">
        <wsdl:operation name="acceptMessage">
            <wsdl:input message="tns:acceptMessage" name="acceptMessage">
            </wsdl:input>
            <wsdl:output message="tns:acceptMessageResponse" name="acceptMessageResponse">
            </wsdl:output>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="PORX_IN02016001SACYLSoapBinding" type="tns:PORX_IN02016001SACYL">
        <soap:binding style="document"
            transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="acceptMessage">
            <soap:operation soapAction="" style="document" />
            <wsdl:input name="acceptMessage">
                <soap:body use="literal" />
            </wsdl:input>
            <wsdl:output name="acceptMessageResponse">
                <soap:body use="literal" />
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="PORX_IN02016001SACYL">
        <wsdl:port binding="tns:PORX_IN02016001SACYLSoapBinding"
            name="PORX_IN02016001SACYL">
            <soap:address
                location="http://localhost:8080/vere/services/PORX_IN02016001SACYL" />
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>
Burble answered 10/1, 2017 at 8:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.