3

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 スキーマがこの形式の場合、アンマーシャリングする方法を教えてください。<error>ルート要素の一部です<response>

Restful クライアントを使用しており、resttemplate を使用してサーバーにリクエストを送信しています。リクエストとレスポンスの XML をマーシャリングおよびアンマーシャリングするための私のapplicationcontext.xml用途。org.springframework.http.converter.xml.MarshallingHttpMessageConverter

4

2 に答える 2

0

xsdはありますか?xsdで要素を定義する必要があると思います

于 2011-10-05T02:22:11.417 に答える
0

おそらく、別のスキーマにある要素responseへの参照があるerror要素のスキーマがあります(残念ながら、スキーマは同じファイルに複数の名前空間を持つことはできません)。要素を含む別のスキーマ ファイルにはerror、targetNamespace がありません。

于 2011-10-05T02:59:22.063 に答える