gpt4 book ai didi

java - SoapFaultClientException : outputting detail

转载 作者:行者123 更新时间:2023-12-01 16:47:29 27 4
gpt4 key购买 nike

我有一个 org.springframework.ws.soap.client.SoapFaultClientException 对象。我想获取其中包含的详细信息以用于记录目的,但我发现很难确定如何执行此操作。

Exception.getFaultStringOrReason() 方法会给我一条基本的错误消息。但是,我需要获取对象故障详细信息中包含的更多详细信息。 SOAP 响应如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<soap:Fault xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<faultcode>soap:Client</faultcode>
<faultstring>The values from the client failed to pass validation.</faultstring>
<detail>
<Errors>
<Error reason="Required on input.">
<ErrorLocation>
<Node level="1" name="MyElement"/>
<Node level="2" name="MyField"/>
</ErrorLocation>
<Parameters/>
<StackTrace/>
</Error>
</Errors>
</detail>
</soap:Fault>

我已经迭代了许多 org.springframework.ws.soap.SoapFaultDetailElement 对象,但我无法获取其中包含的详细信息。这可以吗?

预先感谢您的帮助

最佳答案

这应该有效

} catch (SoapFaultClientException e) {
log.error(e);
SoapFaultDetail soapFaultDetail = e.getSoapFault().getFaultDetail();
SoapFaultDetailElement detailElementChild = (SoapFaultDetailElement) soapFaultDetail.getDetailEntries().next();
Source detailSource = detailElementChild.getSource();

try {
return (JAXBElement<SearchResponse>) getWebServiceTemplate().getUnmarshaller().unmarshal(detailSource).getValue();
} catch (IOException e1) {
throw new IllegalArgumentException("cannot unmarshal SOAP fault detail object: " + soapFaultDetail.getSource());
}
}

关于java - SoapFaultClientException : outputting detail,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47277046/

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