读取 WSO2 EI 中的 LocalEntry 值
To read LocalEntry values in WSO2 EI
我正在尝试根据动态用户输入读取本地条目值(如果Feed 是用户输入,然后应该获取 Feed 中的值(主机、用户、密码等)。但我没有获取值。有人可以建议我实现这个吗?
LocalEntry:
<?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 type.But我不知道如何通过动态检索值。
<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
我正在尝试根据动态用户输入读取本地条目值(如果Feed 是用户输入,然后应该获取 Feed 中的值(主机、用户、密码等)。但我没有获取值。有人可以建议我实现这个吗?
LocalEntry:
<?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 type.But我不知道如何通过动态检索值。
<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