java - Getting an unmarshaling exception in Jaxb -
i have implemented rest web services using apache cxf (no spring framework) , marshaling have used jaxb. when use url in web browser, fine , got object representation in xml format when used client call web service , try unmarshal response in xml format list of object had on server. getting following exception
javax.xml.bind.unmarshalexception: unexpected element (uri:"", local:"html"). expected elements <{}abc>,<{}xyz> @ com.sun.xml.bind.v2.runtime.unmarshaller.unmarshallingcontext.handleevent(unmarshallingcontext.java:662) @ com.sun.xml.bind.v2.runtime.unmarshaller.loader.reporterror(loader.java:258) @ com.sun.xml.bind.v2.runtime.unmarshaller.loader.reporterror(loader.java:253) @ com.sun.xml.bind.v2.runtime.unmarshaller.loader.reportunexpectedchildelement(loader.java:120) @ com.sun.xml.bind.v2.runtime.unmarshaller.unmarshallingcontext$defaultrootloader.childelement(unmarshallingcontext.java:1063) @ com.sun.xml.bind.v2.runtime.unmarshaller.unmarshallingcontext._startelement(unmarshallingcontext.java:498) @ com.sun.xml.bind.v2.runtime.unmarshaller.unmarshallingcontext.startelement(unmarshallingcontext.java:480) @ com.sun.xml.bind.v2.runtime.unmarshaller.saxconnector.startelement(saxconnector.java:150) @ org.apache.xerces.parsers.abstractsaxparser.startelement(unknown source) @ org.apache.xerces.impl.xmlnsdocumentscannerimpl.scanstartelement(unknown source) @ org.apache.xerces.impl.xmlnsdocumentscannerimpl$nscontentdispatcher.scanrootelementhook(unknown source) @ org.apache.xerces.impl.xmldocumentfragmentscannerimpl$fragmentcontentdispatcher.dispatch(unknown source) @ org.apache.xerces.impl.xmldocumentfragmentscannerimpl.scandocument(unknown source) @ org.apache.xerces.parsers.xml11configuration.parse(unknown source) @ org.apache.xerces.parsers.xml11configuration.parse(unknown source) @ org.apache.xerces.parsers.xmlparser.parse(unknown source) @ org.apache.xerces.parsers.abstractsaxparser.parse(unknown source) @ org.apache.xerces.jaxp.saxparserimpl$jaxpsaxparser.parse(unknown source) @ com.sun.xml.bind.v2.runtime.unmarshaller.unmarshallerimpl.unmarshal0(unmarshallerimpl.java:218) @ com.sun.xml.bind.v2.runtime.unmarshaller.unmarshallerimpl.unmarshal(unmarshallerimpl.java:190) @ javax.xml.bind.helpers.abstractunmarshallerimpl.unmarshal(unknown source) @ javax.xml.bind.helpers.abstractunmarshallerimpl.unmarshal(unknown source)
my client code
string uri = "path"; url url = new url(uri); httpurlconnection connection = (httpurlconnection) url.openconnection(); connection.setrequestmethod("get"); connection.setrequestproperty("accept", "application/xml"); jaxbcontext jc = jaxbcontext.newinstance(abc.class); inputstream xml = connection.getinputstream(); abc obj =(abc) jc.createunmarshaller().unmarshal(xml);
Comments
Post a Comment