从 MessageContext 中提取完整的信封 xml
我有一个这样的拦截器:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不需要编写一个,API 中已有一个 -
SoapEnvelopeLoggingInterceptor
。请参阅 javadoc。如果您只需要查看有效负载,而不是整个 SOAP 信封,那么可以使用 PayloadLoggingInterceptor。
You don't need to write one, there's an existing one in the API -
SoapEnvelopeLoggingInterceptor
. See the javadoc.If you only need to see the payload, rather than the entire SOAP envelope, then there's
PayloadLoggingInterceptor
.