解组不属于命名空间的xml元素

时间:2011-06-15 05:48:42

标签: java xml spring namespaces unmarshalling

我有来自网络服务的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架构采用此格式时,如何解组? <error>是根元素<response>的一部分。

我正在使用Restful客户端并使用resttemplate向服务器发出请求。我的applicationcontext.xml使用org.springframework.http.converter.xml.MarshallingHttpMessageConverter来编组和解组请求和响应XML。

2 个答案:

答案 0 :(得分:0)

你有xsd吗?我认为元素应该在你的xsd

中定义

答案 1 :(得分:0)

据推测,你有一个response元素的模式,它有一个error元素的引用,它位于一个单独的模式中(遗憾的是,模式中的模式不能有多个名称空间)同一个文件)。带有error元素的单独模式文件将没有targetNamespace。

相关问题