2011-06-15 65 views
3

的一部分,我有一個XML響應來自web服務來:解組XML元素是不是命名空間

<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> 

如何解組時,XML Schema是這種格式。 <error>是根元素<response>的一部分。

我正在使用Restful客戶端並使用resttemplate向服務器發出請求。我的applicationcontext.xml使用org.springframework.http.converter.xml.MarshallingHttpMessageConverter進行編組和解組請求和響應XML。

回答

0

你有沒有xsd?我認爲元素應該定義在你的xsd

0

大概你有一個response元素的模式,它有一個對error元素的引用,它在一個單獨的模式中(不幸的是,模式不能有多個名稱空間在同一個文件中)。帶有error元素的獨立模式文件將不包含targetNamespace。