gpt4 book ai didi

spring & web service 客户端 - 故障详情

转载 作者:行者123 更新时间:2023-12-04 16:50:23 24 4
gpt4 key购买 nike

关闭。这个问题是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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com