关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。
想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。
去年关闭。
Improve this question
如何获得 SoapFaultClientException 发送的故障详细信息?
我使用 WebServiceTemplate ,如下所示:
WebServiceTemplate ws = new WebServiceTemplate();
ws.setMarshaller(client.getMarshaller());
ws.setUnmarshaller(client.getUnMarshaller());
try {
MyResponse resp = (MyResponse) = ws.marshalSendAndReceive(WS_URI, req);
} catch (SoapFaultClientException e) {
SoapFault fault = e.getSoapFault();
SoapFaultDetail details = e.getSoapFault().getFaultDetail();
//details always NULL ? Bug?
}
发送的 Web 服务故障似乎是正确的:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Client</faultcode>
<faultstring>Validation error</faultstring>
<faultactor/>
<detail>
<ws:ValidationError xmlns:ws="http://ws.x.y.com">ERR_UNKNOWN</ws:ValidationError>
</detail>
</soapenv:Fault>
</soapenv:Body>
谢谢
威洛姆
最佳答案
我还遇到了 getFaultDetail() 返回 null(对于 SharePoint Web 服务)的问题。我可以使用与此类似的方法获取 detail 元素:
private Element getDetail(SoapFaultClientException e) throws TransformerException {
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMResult result = new DOMResult();
transformer.transform(e.getSoapFault().getSource(), result);
NodeList nl = ((Document)result.getNode()).getElementsByTagName("detail");
return (Element)nl.item(0);
}
之后,您可以对返回的 Element 或您想要的任何内容调用 getTextContent()。
关于spring & web service 客户端 - 故障详情,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/100990/