我是Enterprise Integrator的新手,因此我可能面临一个误解问题。 我在Linux机器上安装了WSO2 EI 6.1.1。 我已经为一个非常简单的基于表单的Web应用程序创建了一个代理传递,它完美地运行。
我想先通过验证对外部服务器的休息请求来过滤对它的访问。 此外部请求的JSON结果应包含特定值fe {"valid":"yes"} 。
我创建了一个Java类,可以进行此调用(目前只是静态分配值并将其加载到变量中):
public class validate extends AbstractMediator { private String validated = "yes"; public boolean mediate(MessageContext context) { System.out.println("Validating Access!!!!"); System.out.println("Validated: " + validated); return true; } public String getValidated() { return validated; } public void setValidated(String validated) { this.validated = validated; }我看它运行正常。
作为第二步,我创建了一个Mediator过滤器,目的是评估这个值。 我用一个始终真实的xpath expresion 1 > 0测试这个中介我看到then和else子句正常工作。
我无法检查过滤器介体中第一个介体中获得的值。 我怎样才能做到这一点? 我错过了什么?
更新:
我发现解决问题的明显方法是定义一个Property mediator来存储值。 我已设法使用属性在过滤器中做出决定但是,如何使用在Java类中获得的值设置该属性?
I am new to Enterprise Integrator so I may be facing a misunderstanding problem. I have installed WSO2 EI 6.1.1 on a Linux box. I have created a pass through proxy for a very simple form based web application and it works perfectly.
I want to filter the access to it by previoulsy validating a rest request to an external server. The JSON result of this external request should contain an specific value, f.e. {"valid":"yes"}.
I have created a Java class taht can make this call (at the present is just assigning statically the value and loading it in a variable):
public class validate extends AbstractMediator { private String validated = "yes"; public boolean mediate(MessageContext context) { System.out.println("Validating Access!!!!"); System.out.println("Validated: " + validated); return true; } public String getValidated() { return validated; } public void setValidated(String validated) { this.validated = validated; }I see it running correctly.
As a second step I have created a Mediator filter with the aim of evaluating this value. I have tested this mediator with an always true xpath expresion 1 > 0 And I see that the then and else clauses work correctly.
I have not been able to check the value obtained in the first mediator in the filter mediator. How can I do this? What am I missing?
UPDATE:
I have found that the apparent way of solving the problem is defining a Property mediator to store the value. I have managed to use a property to make the decision in the filter but, how can I set that property with a value obtained in the Java class?
最满意答案
你只需要在你的java类中添加这一行:mc.setProperty(“MyPropertyName”,myValue);
在您的中介中,使用get-property(“MyPropertyName”);
You just need to add this line in your java class : mc.setProperty("MyPropertyName", myValue);
In your mediation, use get-property("MyPropertyName");
更多推荐
发布评论