将 SOAP 体中发现的 SOAP 故障移至 Spring Web 服务中发现的响应的 SOAP 头的最佳方法是什么?有什么例子吗?
我可以拦截错误,但我不认为我可以用这个解析器修改任何内容。
public class LisSoapFaultTranslatorExceptionResolver extends SoapFaultMappingExceptionResolver {
@Override
protected void customizeFault(Object endpoint, Exception ex, SoapFault fault) {
fault = null;
}
}
最佳答案
来自W3Schools ,
The optional SOAP Fault element is used to indicate error messages.
If a Fault element is present, it must appear as a child element of the Body element. A Fault element can only appear once in a SOAP message.
如果您的 SOAP 错误位于响应的头部,则您的 SOAP 信封不再遵循规范。你不应该那样做。我怀疑实现 SOAP 接口(interface)的框架是否能让您做到这一点。
要被识别为携带 SOAP 错误信息,SOAP 消息必须包含单个 SOAP Fault 元素信息项作为 SOAP Body 的唯一子元素信息项。
来自 Spec
To be recognized as carrying SOAP error information, a SOAP message MUST contain a single SOAP Fault element information item as the only child element information item of the SOAP Body .
When generating a fault, SOAP senders MUST NOT include additional element information items in the SOAP Body . A message whose Body contains a Fault plus additional element information items has no SOAP-defined semantics.
A SOAP Fault element information item MAY appear within a SOAP header block, or as a descendant of a child element information item of the SOAP Body ; in such cases, the element has no SOAP-defined semantics.
重要的是如果您这样做,该元素没有 SOAP 定义的语义
。我认为这件事你只能靠自己了。如果没有错误,也许可以使用 Spring 生成 SOAP 响应,否则自己生成。
关于java - 使用 Spring WS 将故障从皂体移至皂头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15528509/