从 MessageContext 中提取完整的信封 xml

发布于 2024-11-24 23:07:05 字数 711 浏览 1 评论 0原文

我有一个这样的拦截器:

public class WebServiceInterceptor extends EndpointInterceptorAdapter {

@Inject
private Jaxb2Marshaller myJaxb2Marshaller;

@Inject
private WebServiceHistoryDao webServiceHistoryDao;

@Override
public boolean handleRequest(MessageContext messageContext, Object endpoint)
        throws Exception {

    Source payloadSource = messageContext.getRequest().getPayloadSource();
    Object unmarshaled = myJaxb2Marshaller.unmarshal(payloadSource);

    //EXTRACT XML HERE
    //is there a better way than this:
    String extractedXml = myJaxb2Marshaller.marshal(unmarshaled);

    return true;
}

}

How can i extract the full xml of letter (出于日志记录目的 - 将其写入数据库)

I have an interceptor like this:

public class WebServiceInterceptor extends EndpointInterceptorAdapter {

@Inject
private Jaxb2Marshaller myJaxb2Marshaller;

@Inject
private WebServiceHistoryDao webServiceHistoryDao;

@Override
public boolean handleRequest(MessageContext messageContext, Object endpoint)
        throws Exception {

    Source payloadSource = messageContext.getRequest().getPayloadSource();
    Object unmarshaled = myJaxb2Marshaller.unmarshal(payloadSource);

    //EXTRACT XML HERE
    //is there a better way than this:
    String extractedXml = myJaxb2Marshaller.marshal(unmarshaled);

    return true;
}

}

How can i extract the whole xml of envelope (for logging purposes - to write it to the DB)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眉黛浅 2024-12-01 23:07:05

您不需要编写一个,API 中已有一个 - SoapEnvelopeLoggingInterceptor。请参阅 javadoc

特定于 SOAP 的 EndpointInterceptor,用于记录 SoapMessage 消息的完整请求和响应信封。默认情况下,会记录请求、响应和故障消息,但可以使用 logRequestlogResponselogFault 属性更改此行为。 p>

如果您只需要查看有效负载,而不是整个 SOAP 信封,那么可以使用 PayloadLoggingInterceptor。

You don't need to write one, there's an existing one in the API - SoapEnvelopeLoggingInterceptor. See the javadoc.

SOAP-specific EndpointInterceptor that logs the complete request and response envelope of SoapMessage messages. By default, request, response and fault messages are logged, but this behaviour can be changed using the logRequest, logResponse, logFault properties.

If you only need to see the payload, rather than the entire SOAP envelope, then there's PayloadLoggingInterceptor.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文