Unmarshalling an xml element which is not part of namespace
I have an xml response coming from a webservice:
<ns2:response xmlns:ns2="http://abc.com">
<ns2:msgHeader>
<ns2:empid>1234</ns2:empid>
<ns2:empname>John</ns2:empid>
</ns2:msgHeader>
<error>
<httpstatus>500</httpstatus>
<description>Error while processing the request.Please contact customercare</description>
</error>
</ns2:response>
How do I unmarshall when the xml schema is in this format. <error>
is part of the root element <response>
.
I am using Restful client and using resttemplate to make the request to the server. My applicationcontext.xml
uses org.springframework.http.converter.xml.MarshallingHttpMessageConverter
for marshalling and unmarshalling the request and response XMLs开发者_C百科.
Do you have an xsd? I presume element should be defined in your xsd
presumably, you have a schema for the response
element, where it has a reference to the error
element, which is in a separate schema (unfortunately, schemas cannot have more than one namespace in the same file). the separate schema file with the error
element will have no targetNamespace.
精彩评论