Announcement Announcement Module
Collapse
No announcement yet.
JAXBElement<String> unmarshalling Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JAXBElement<String> unmarshalling

    Hello,

    im using org.springframework.oxm.jaxb.Jaxb2Marshaller in endpoints and clients. I have problem unmarhsalling simple JAXBElements which are not mapped in marshaller/umharshaller. My endpoint method looks like this:

    Code:
    @PayloadRoot(localPart = "GetXRequest", namespace = "http://namespace")
    public JAXBElement<String> getX(GetXRequest request) {
            return of.createGetXResponse("test");
    }
    where of is my generated ObjectFactory.

    createGetXResponse looks like this:

    Code:
    private final static QName _GetXResponse_QNAME = new QName("http://namespace", "GetXResponse");
        
    
    @XmlElementDecl(namespace = "http://namespace", name = "GetXResponse")
        public JAXBElement<String> createGetXResponse(String value) {
            return new JAXBElement<String>(_GetXResponse_QNAME, String.class, null, value);
        }
    My client is trying to use web service's endpoint method:
    Code:
    ObjectFactory of = new ObjectFactory();
    GetXRequest request = 
                of.createGetXRequest();
    Object result = getWebServiceTemplate().marshalSendAndReceive(request);
    and i get following exception:

    Code:
    org.springframework.oxm.jaxb.JaxbUnmarshallingFailureException: JAXB unmarshalling exception: unexpected element (uri:"http://namespace", local:"GetXResponse"). Expected elements are ...
    So, how should i unmarshall simple JAXBElements which are not maped in marshaller? Or should i somehow map them? How?

    Thanks

    Gravy

  • #2
    Solution

    resolved this issue using property "contextPaths" instead of using property "classesToBeBound" of the org.springframework.oxm.jaxb.Jaxb2Marshaller

    Comment

    Working...
    X