wso2 - 读取 WSO2 EI 中的 LocalEntry 值
问题描述
我正在尝试根据动态用户输入读取本地条目值(如果Feed是用户输入,则应获取 Feed 中的值(主机、用户、密码等)。但没有为我获取值。任何人都可以建议我实现这个?
本地入口:
<?xml version="1.0" encoding="UTF-8"?>
<localEntry xmlns="http://ws.apache.org/ns/synapse" key="MailTo_Details">
<MAIL_Details xmlns="http://mail.com/localentry">
<Lead>
<credentials>
<host>smtp.gmail.com</host>
<port>587</port>
<starttls.enable>true</starttls.enable>
<auth>false</auth>
<user>Demouser</user>
<password>email1pws</password>
<from>email1@gmail.com</from>
</credentials>
</Lead>
<Feed>
<credentials>
<host>smtp.gmail.com</host>
<port>587</port>
<starttls.enable>true</starttls.enable>
<auth>false</auth>
<user>Testuser</user>
<password>email2pws</password>
<from>email2@gmail.com</from>
</credentials>
</Feed>
</MAIL_Details>
<description/>
</localEntry>
我已加载 localentry 并将值设置为 OM 类型。但我不知道动态检索值的方法。
<property xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"
xmlns:ns="http://org.apache.synapse/xsd"
xmlns:ns3="http://org.apache.synapse/xsd"
name="mailConfig"
expression="get-property('MailTo_Details')"
scope="default"
type="OM"/>
解决方案
试试这个代理:
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="loadPayloadfromLocalEntry" startOnLoad="true" transports="http https" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<property expression="get-property('MailTo_Details')" name="mailConfig" scope="default" type="OM" xmlns:ns="http://org.apache.synapse/xsd" xmlns:ns3="http://org.apache.synapse/xsd" xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"/>
<property name="getinput" scope="default" type="STRING" expression="$body/getdata/mailinput"/>
<property name="apos" scope="default" type="STRING" value="'"/>
<log>
<property name="printValueEmail" expression="$ctx:mailConfig"/>
<property name="getinput" scope="default" type="STRING" expression="$body/getdata/mailinput"/>
<property name="HOST" expression="evaluate(fn:concat('$ctx:mailConfig//ns:',get-property('getinput'),'/ns:credentials/ns:host'))" xmlns:ns="http://mail.com/localentry"/>
</log>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</target>
</proxy>
以有效载荷为主体:
<body>
<getdata>
<mailinput>Feed</mailinput>
</getdata>
</body>
我的日志消息:
[2020-07-27 11:39:32,487] INFO {org.apache.synapse.mediators.builtin.LogMediator} - To: /services/loadPayloadfromLocalEntry.loadPayloadfromLocalEntryHttpSoap12Endpoint, WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:bc74622a-3843-4813-ab35-769138d5f8e6, Direction: request, printValueEmail = <MAIL_Details xmlns="http://mail.com/localentry">
<Lead>
<credentials>
<host>smtp.gmail.com</host>
<port>587</port>
<starttls.enable>true</starttls.enable>
<auth>false</auth>
<user>Demouser</user>
<password>email1pws</password>
<from>email1@gmail.com</from>
</credentials>
</Lead>
<Feed>
<credentials>
<host>smtp.gmail.com</host>
<port>587</port>
<starttls.enable>true</starttls.enable>
<auth>false</auth>
<user>Testuser</user>
<password>email2pws</password>
<from>email2@gmail.com</from>
</credentials>
</Feed>
</MAIL_Details>, getinput = Feed, HOST = smtp.gmail.com
推荐阅读
- android - 重新绑定 CameraX 用例
- php - 为什么我在服务器上的路由不起作用 - 使用 Laravel 6.0?
- r - sp::over()。该点是否属于使用 OGRGeoJSON 文件标识的多边形之一?
- angular - 向 mat 表单字段添加验证
- docker - Docker hub 不断超时并在大镜像层上重试直到失败
- c - 用 C 求方程的根
- c# - 将变量从类返回到 MainForm
- java - Struts 2 - 从数据库填充下拉列表
- powershell - 如何添加/替换 psobject
- ruby-on-rails - heroku .rvm/gems/ruby-2.4.0/bin/heroku:没有这样的文件或目录