нαƒ*_*єєz 6 java xml spring xsd resttemplate
我通过Spring RestTemplate将XML over HTTP请求发送到外部网关,然后我收到了XML响应.
为验证响应而提供的XSD具有目标命名空间,但实际响应不包含命名空间前缀.我使用XSD生成了Java资源,因此在获取响应时(在解组过程中)我遇到了以下错误,
ResponseEntity<Response> responseEntity = restTemplate.exchange(endpointURL, HttpMethod.POST, requestEntity,
Response.class);
Run Code Online (Sandbox Code Playgroud)
例外是: -
Exception in thread "main" javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"Response"). Expected elements are <{http://securetransport.dw/rcservice/xml}Response>
Run Code Online (Sandbox Code Playgroud)
有没有办法跳过Spring ResponseEntity的命名空间检查?
小智 2
如果您使用 jaxb-plugin 生成了绑定,则应该有一个“package-info.java”。
例如:
@javax.xml.bind.annotation.XmlSchema( namespace = "someurl", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED )
如果您从注释中删除名称空间,它应该可以工作。
| 归档时间: |
|
| 查看次数: |
815 次 |
| 最近记录: |