Wso2 Enterprise Integrator介体过滤器和外部源(Wso2 Enterprise Integrator mediator filter and external sources)

编程入门 行业动态 更新时间:2024-10-26 17:24:30
Wso2 Enterprise Integrator介体过滤器和外部源(Wso2 Enterprise Integrator mediator filter and external sources)

我是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");

更多推荐

本文发布于:2023-07-17 04:44:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1139259.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:过滤器   Integrator   Enterprise   sources   external

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!