如何修改生成的SOAP请求?
我正处于创建输出拦截器并从 SOAP 消息中获取 OuputStream 的阶段。但是,如何在将 SOAP 信封发送到端点之前对其进行修改呢?我想删除一些 xml 元素。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我正处于创建输出拦截器并从 SOAP 消息中获取 OuputStream 的阶段。但是,如何在将 SOAP 信封发送到端点之前对其进行修改呢?我想删除一些 xml 元素。
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
一种方法是获取文档并通过 XSLT 转换运行它。
您可以通过调用仔细来获取拦截器的handleMessage中的文档,
但如果您有安全性,例如必须对soap内容执行XML签名,则必须确保您的拦截器在应用签名之前发生,否则您将使它们无效。
要调整拦截器的时间,您可以指定它将运行的阶段。如果它们在同一阶段执行,CXF 还应该遵循您配置它们的顺序。
但不要相信我的话...检查这些以获取更多信息
通过CXF源代码进行调试也帮助我理解了它的工作原理
----编辑 ----
(感谢 Daniel :-)
要实现此功能,您需要在堆栈中配置 SAAJOutInterceptor。您可以手动添加它,也可以简单地将其作为拦截器的一部分。 这是一个拦截器的示例,它几乎可以完成您的任务想。
one way could be to get the document and run it through XSLT transform.
You can get at the document in the handleMessage of your interceptor by calling
careful though that if you have security such as XML signature that must be performed on the soap content you must ensure that your interceptor occurs BEFORE the signature are applied otherwise you will invalidate them.
To play around with the timing of the interceptor you can specify the phase at which it will run. CXF should also honor the order in which you will configure them should they be performed at the same phase.
but don't take my word for it... check these for more info
debugging through the CXF source code also helped me a great deal in understanding how it worked
---- EDIT ----
(thanks Daniel :-)
For this to work you need to have SAAJOutInterceptor configured in your stack. You can either add it manually or simply make it part of your interceptor. Here is an example of an interceptor that pretty much does what you want.
有关拦截器阶段的说明,请参阅此链接
https://web.archive.org/web/20131003140105/http://fusesource.com/docs/esb/4.2/cxf_interceptors/CXFInterceptPhasesAppx.html
Refer to this link for a description of the Interceptor Phases
https://web.archive.org/web/20131003140105/http://fusesource.com/docs/esb/4.2/cxf_interceptors/CXFInterceptPhasesAppx.html
我在这里发布了答案 https://stackoverflow.com/a/12948702/792313
它基于全身替代。
I posted an answer here https://stackoverflow.com/a/12948702/792313
It is based on the whole body substitution.