wso2 esb_使用WSO2 ESB进行邮件内容过滤
wso2 esb
  每個集成設計師或開發人員都應該熟悉Gregor Hohpe和Bobby Woolf所描述的企業集成模式(EIP) 。 模式之一是“內容消息過濾器” (不要與消息過濾器模式混淆)。 
 使用不同的Mediator在WSO2中有多種方法可以實現此目的。 一種方法是使用XSLT介體 ,您可以在其中簡單地使用XSLT進行過濾。 另一個(根據名稱不那么明顯)是Enrich Mediator 。 
這是一個如何使用Enrich Mediator的示例。 想象一下原始消息是:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tmp="http://www.pascalalma.net/order"><soapenv:Header/><soapenv:Body><tmp:message><tmp:document><tmp:order><tmp:id>123</tmp:id></tmp:order></tmp:document></tmp:message></soapenv:Body> </soapenv:Envelope>我們真正想要的是一條僅以“ order”元素為有效載荷的Soap消息。 我們可以使用具有以下配置的Enrich介體來完成此操作:
<enrich xmlns:tmp="http://www.pascalalma.net/order"><source clone="false" type="custom" xpath="//tmp:document/*" /><target action="replace" type="body" /> </enrich>因此,通過這種配置,我們告訴中介者應將'document'元素的內容作為源,并將此內容放入傳入的SOAP消息的正文中。
當您選擇使用XSLT介體時,這里有一個示例XSLT,可用于從XML文檔中刪除某些元素。 您可以在以下XML消息上使用它:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tmp="http://www.pascalalma.net/order"><soapenv:Header/><soapenv:Body><tmp:message><tmp:document><tmp:order><tmp:id>123</tmp:id><tmp:type>backorder</tmp:type><tmp:status>open</tmp:status><tmp:description>open</tmp:description></tmp:order></tmp:document></tmp:message></soapenv:Body> </soapenv:Envelope>如果我們想要這個相同的XML文檔,但是沒有元素'tmp:type'和'tmp:description',我們可以這樣定義XSLT介體:
<xslt key="xslt/remove-elements-v1.xslt" description="remove unwanted elements"><property name="removeElementsNamed" value="type,description" /> </xslt>使這項工作有效的XSLT代碼(我在stackoverflow網站上找到了它):
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output omit-xml-declaration="no" indent="yes" encoding="UTF-8"/><xsl:strip-space elements="*"/><xsl:param name="removeElementsNamed" /><xsl:template match="node()|@*"><xsl:copy><xsl:apply-templates select="node()|@*"/></xsl:copy></xsl:template><xsl:template match="*[local-name()=tokenize($removeElementsNamed,'[\|, \t]')]"/> </xsl:stylesheet>請注意,此XSLT不會考慮名稱空間,只會刪除所有本地名稱與提供的名稱匹配的元素!
翻譯自: https://www.javacodegeeks.com/2015/03/message-content-filtering-with-wso2-esb.html
wso2 esb
總結
以上是生活随笔為你收集整理的wso2 esb_使用WSO2 ESB进行邮件内容过滤的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: DDOS攻击检测(内网ddos攻击检测)
- 下一篇: 备案地是指哪里(备案地是指)
