小编use*_*714的帖子

spring&web服务客户端 - 故障详细信息

我如何获得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?
}
Run Code Online (Sandbox Code Playgroud)

发送的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>
Run Code Online (Sandbox Code Playgroud)

谢谢

Willome

service spring webservicetemplate

5
推荐指数
3
解决办法
1万
查看次数

标签 统计

service ×1

spring ×1

webservicetemplate ×1