Results 1 to 5 of 5

Thread: Unmarshaller error, please help

  1. #1
    Join Date
    May 2006
    Posts
    111

    Default Unmarshaller error, please help

    I get following error.

    HTML Code:
    00:44:51,343  DEBUG [http-8081-1] - SoapMessageDispatcher - Endpoint mapping [org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping@c9537b] maps request to endpoint [com.ats.fts.webservice.SessionEndpoint@2870b7]
    00:44:51,343  DEBUG [http-8081-1] - PayloadLoggingInterceptor - Request: <ExternalRequest xmlns="http://abc.com/xyz/schemas"><EFEReqeust><UserName>TEST</UserName><Password>password</Password><MessageId>1012</MessageId><MessageTag>1234</MessageTag><MessageText>13380</MessageText></EFEReqeust></ExternalRequest>
    00:44:51,343  DEBUG [http-8081-1] - SoapMessageDispatcher - Testing endpoint adapter [org.springframework.ws.server.endpoint.adapter.MessageEndpointAdapter@2b7bd9]
    00:44:51,375  DEBUG [http-8081-1] - SoapMessageDispatcher - Testing endpoint exception resolver [org.springframework.ws.soap.server.endpoint.SimpleSoapExceptionResolver@419e74]
    00:44:51,390   WARN [http-8081-1] - SoapMessageDispatcher - Endpoint invocation resulted in exception - responding with SOAP Fault
    org.springframework.oxm.jaxb.JaxbUnmarshallingFailureException: JAXB unmarshalling exception: unexpected element (uri:"http://abc.com/xyz/schemas", local:"ExternalRequest"). Expected elements are <{}ExternalRequest>; nested exception is javax.xml.bind.UnmarshalException: unexpected element (uri:"http://abc.com/xyz/schemas", local:"ExternalRequest"). Expected elements are <{}ExternalRequest>
    Caused by: 
    javax.xml.bind.UnmarshalException: unexpected element (uri:"http://abc.com/xyz/schemas", local:"ExternalRequest"). Expected elements are <{}ExternalRequest>
    	at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:603)
    	at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:244)
    	at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:239)
    	at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:116)
    	at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement(UnmarshallingContext.java:1009)
    	at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:446)
    	at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:427)
    	at com.sun.xml.bind.v2.runtime.unmarshaller.ValidatingUnmarshaller.startElement(ValidatingUnmarshaller.java:90)
    	at com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.startElement(InterningXmlVisitor.java:71)
    	at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:137)
    where schema looks as below.
    HTML Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cfts="http://abc.com/xyz/schemas" elementFormDefault="qualified"
            targetNamespace="http://abc.com/xyz/schemas">
        <xs:element name="ExternalRequest">
            <xs:complexType>
                <xs:all>
                    <xs:element name="EFEReqeust" type="cfts:EFERequestType"/>                       
                </xs:all>
            </xs:complexType>
        </xs:element>
        <xs:complexType name="EFERequestType">
            <xs:sequence>
            	<xs:element name="UserName" type="xs:string"/>
                <xs:element name="Password" type="xs:string"/>
                <xs:element name="MessageId" type="xs:string"/> 
                <xs:element name="MessageTag" type="xs:string"/>
                <xs:element name="MessageText" type="xs:string"/>
            </xs:sequence>                                                                   
        </xs:complexType>
    </xs:schema>
    And I generated classes using xjc. here is how XML request string is being composed from client code.
    HTML Code:
    private static final String MESSAGE = "<ExternalRequest xmlns=\"http://abc.com/xyz/schemas\"><EFEReqeust>"+ 
    	  									  "<UserName>User</UserName>"+ 
    										  "<Password>password</Password>"+
    										  "<MessageId>1012</MessageId>"+ 
    										  "<MessageTag>1234</MessageTag>"+ 
    									      "<MessageText>13380</MessageText>"+ 
    										"</EFEReqeust></ExternalRequest>";
    Any idea what is wrong in here?

    Thanks,

  2. #2
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    By the looks of it, everything looks good. How did you configure the Jaxb2Marshaller?
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  3. #3

    Default

    I think the problem occurs because your java project isn't being built properly. It seems that the package-info.java, generated by xjc, is not being included in the build process.
    Are you using netbeans by any chance? If so, try using the "Build" command instead of running your main class directly.
    Tareq Abedrabbo

    My Twitter
    My Blog

  4. #4
    Join Date
    May 2006
    Posts
    111

    Default

    Quote Originally Posted by tareq View Post
    I think the problem occurs because your java project isn't being built properly. It seems that the package-info.java, generated by xjc, is not being included in the build process.
    Are you using netbeans by any chance? If so, try using the "Build" command instead of running your main class directly.
    you are the man. I was always deliberately ignoring package-info.java from my build. now can you explain why is this class required. Had I not generated classes using xjc but created manually, I wouldn't have this class. can you explain?

    Thanks a lot,

  5. #5

    Default

    package-info.java is the source file that contains annotations targeting the package. In your case, it contains @javax.xml.bind.annotation.XmlSchema(namespace = "http://abc.com/xyz/schemas") which binds the JAXB2 generated classes to the specified namespace.
    See the following links for more details:
    http://java.sun.com/docs/books/jls/t...ges.html#97192
    http://www.onjava.com/pub/a/onjava/2...ve.html?page=3
    Tareq Abedrabbo

    My Twitter
    My Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •