Apache CXF 3.2 如何读取 SOAP 错误消息



>我正在尝试从 CXF 拦截器读取 SOAP 错误消息,但我无法提取,我捕获了 Fidler 的响应

以下是小提琴手的回应

--uuid:0674d395-99e7-44d8-966c-1f1d387f4234
Content-Id: <rootpart*0674d395-99e7-44d8-966c-1f1d387f4234@example.jaxws.sun.com>
Content-Type: application/xop+xml;charset=UTF-8;type="text/xml"
Content-Transfer-Encoding: binary
<?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope" xmlns=""><faultcode>S:Server</faultcode><faultstring>Upload Failed!</faultstring></S:Fault></S:Body></S:Envelope>
--uuid:0674d395-99e7-44d8-966c-1f1d387f4234--

以下是我的代码

向客户端添加了故障拦截器

client.getInFaultInterceptors().add(faultInterceptor);
public class FlexFaultResponseInterceptor extends AbstractSoapInterceptor {
    public FlexFaultResponseInterceptor() {
        super(Phase.RECEIVE);
    }
    @Override
    public void handleMessage(SoapMessage message) throws Fault {
        Message InFaultMessage = message.getExchange().getInFaultMessage();
        Message OutFaultMessage = message.getExchange().getOutFaultMessage();
    }
}

我通过将以下代码添加到 InInterceptor 中解决了我的问题

@Override
    public void handleMessage(SoapMessage message) throws Fault {
            CachedOutputStream out = message.getContent(CachedOutputStream.class);
            byte[] originalMessage = IOUtils.toByteArray( out.getInputStream() );
            String fault=new String(originalMessage)
    }

相关内容

  • 没有找到相关文章

最新更新