[英]WSO2 - Enterprise Integrator - Filter Mediator
I am trying to understand how Filter Mediator works.我试图了解过滤介体是如何工作的。 I have a Proxy service that talks to a SOAP API.我有一个与 SOAP API 通信的代理服务。 I tried to introduce Filter Mediator to it for header based routing but it is not working anymore.我试图为基于标头的路由引入过滤器介体,但它不再工作了。
Please see and let me know what I have done wrong here.请查看并让我知道我在这里做错了什么。
soapProxy.xml
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="soapProxy" startOnLoad="true" transports="http https" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<filter regex="test" source="get-property('transport','header1')">
<then>
<log description="ifLog" level="custom">
<property name="value" value="---------- Then Clause ---"/>
</log>
<send>
<endpoint key="SoapEndpoint"/>
</send>
</then>
<else>
<log description="elseLog" level="custom">
<property name="value" value="--- Else Clause ---"/>
</log>
<log description="log1" level="custom" separator="
 ---> ">
<property name="log1.message" value=" ---> printing log1"/>
<property expression="get-property('transport','header1')" name="log1.headerProperty"/>
</log>
<property description="welcomeMsgProperty" name="welcomeMsg" scope="default" type="STRING" value="------ Hello World Property Mediator"/>
<log description="log2" separator="
 ---> ">
<property name="log2.message" value=" -------------> Welcome to Log Mediator"/>
<property expression="get-property("log2.message")" name="log2.MyProperty"/>
<property expression="get-property("MessageID")" name="log2.msgID"/>
<property expression="get-property("welcomeMsg")" name="log2.welcomeMsg"/>
<property expression="$trp:Content-Type" name="log2.stockprop"/>
</log>
<send>
<endpoint key="SoapEndpoint"/>
</send>
</else>
</filter>
</inSequence>
<outSequence>
<log description="resLog" separator="
 ---> ">
<property expression="get-property("welcomeMsg")" name="welcomeMsg"/>
<property name="test" value="*****"/>
</log>
<send/>
</outSequence>
<faultSequence/>
</target>
</proxy>
**SoapEndpoint.xml**
<?xml version="1.0" encoding="UTF-8"?>
<endpoint name="SoapEndpoint" xmlns="http://ws.apache.org/ns/synapse">
<address format="soap12" optimize="swa" uri="http://localhostlocal:9090/ws/countries.wsdl"/>
<property name="ENDPOINT_ADDRESS" value="http://localhost.local:9090/ws/countries.wsdl"/>
</endpoint>
I then tried using sequence Mediator to redirect requests but am getting erroe there too.然后我尝试使用序列中介器来重定向请求,但在那里也出错了。 ERROR - SequenceMediator Sequence named Value {name ='null', keyValue ='sequence1'} cannot be found错误 - 无法找到名为 Value {name ='null', keyValue ='sequence1'} 的 SequenceMediator 序列
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="sequence1" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<send>
<endpoint>
<address uri="http://localhost:9090/ws/countries.wsdl"/>
</endpoint>
</send>
</sequence>
<filter regex="test" source="get-property('transport','header1')">
<then>
<log description="ifLog" level="custom">
<property name="value" value="---------- Then Clause ---"/>
</log>
<sequence key="sequence1"/>
</then>
.....
.....
The following proxy is working for me以下代理对我有用
<?xml version="1.0" encoding="UTF-8"?><proxy xmlns="http://ws.apache.org/ns/synapse" name="soapProxy" startOnLoad="true" statistics="disable" trace="disable" transports="http,https">
<target>
<inSequence>
<filter regex="test" source="get-property('transport','header1')">
<then>
<log level="custom">
<property name="value" value="---------- Then Clause ---"/>
</log>
<send>
<endpoint>
<http uri-template="http://www.mocky.io/v2/5185415ba171ea3a00704eed"/>
</endpoint>
</send>
</then>
<else>
<log level="custom">
<property name="value" value="--- Else Clause ---"/>
</log>
<send>
<endpoint>
<http uri-template="http://www.mocky.io/v2/5185415ba171ea3a00704eed"/>
</endpoint>
</send>
</else>
</filter>
<respond/>
</inSequence>
</target>
<description/>
use following CURL commands.使用以下 CURL 命令。
curl -X POST \\ http://localhost:8280/services/soapProxy \\ -H 'cache-control: no-cache' \\ -H 'content-type: application/json' \\ -H 'header1: test2' \\ -H 'postman-token: d4d1e767-3cd7-39a6-2782-58ab0ffba987' \\ -d ' { "a" : "a" }' curl -X POST \\ http://localhost:8280/services/soapProxy \\ -H 'cache-control: no-cache' \\ -H 'content-type: application/json' \\ -H 'header1: test2' \\ - H '邮递员令牌:d4d1e767-3cd7-39a6-2782-58ab0ffba987' \\ -d ' { "a" : "a" }'
curl -X POST \\ http://localhost:8280/services/soapProxy \\ -H 'cache-control: no-cache' \\ -H 'content-type: application/json' \\ -H 'header1: test' \\ -H 'postman-token: d4d1e767-3cd7-39a6-2782-58ab0ffba987' \\ -d ' { "a" : "a" }' curl -X POST \\ http://localhost:8280/services/soapProxy \\ -H 'cache-control: no-cache' \\ -H 'content-type: application/json' \\ -H 'header1: test' \\ - H '邮递员令牌:d4d1e767-3cd7-39a6-2782-58ab0ffba987' \\ -d ' { "a" : "a" }'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.