滤镜中介器在WSO2 EI 6.6中无法正常工作

发布于 2025-01-28 02:34:58 字数 1990 浏览 3 评论 0原文

我正在尝试通过将过滤器调解器与条件(成功更新的VIN编号更新)在OUT序列中处理响应我在下面提到的代码中误解了。谢谢!

 <outSequence>
        <log level="custom">
            <property expression="json-eval($.)" name="===Response from COMS==="/>
        </log>
        <log level="custom">
            <property expression="json-eval($)" name="ComsResponse"/>
        </log>
        <property expression="json-eval($.ComsResponse)" name="Response" scope="default" type="STRING"/>
        <filter regex="Vin number Updated Successfully" source="$ctx:Response">
            <then>
                <payloadFactory description="Form Response Payload" media-type="json">
                    <format>{"StatusCode":"$1","Message":"$2"}</format>
                    <args>
                        <arg value="200"/>
                        <arg value="Updated Sucessfully"/>
                    </args>
                </payloadFactory>
            </then>
            <else>
                <payloadFactory description="Form Response Payload" media-type="json">
                    <format>{"StatusCode":"$1","Message":"$2"}</format>
                    <args>
                        <arg value="400"/>
                        <arg value="Unable to Created or Vin Number already exist"/>
                    </args>
                </payloadFactory>
            </else>
        </filter>
        <respond/>
        <property description="HTTPStatusCode" name="HTTP_SC" scope="axis2" type="STRING" value="200"/>
        <property description="HttpMessageType" name="messageType" scope="axis2" type="STRING" value="application/json"/>
    </outSequence>

I'm trying to handle the response in the out sequence by using filter mediator with condition as (Vin number Updated Successfully) if it's satisfy Then block needs to be excluded but instead of Then block the else block is executed so Please tell me what did I mistaken in the below mentioned code. Thanks!

 <outSequence>
        <log level="custom">
            <property expression="json-eval($.)" name="===Response from COMS==="/>
        </log>
        <log level="custom">
            <property expression="json-eval($)" name="ComsResponse"/>
        </log>
        <property expression="json-eval($.ComsResponse)" name="Response" scope="default" type="STRING"/>
        <filter regex="Vin number Updated Successfully" source="$ctx:Response">
            <then>
                <payloadFactory description="Form Response Payload" media-type="json">
                    <format>{"StatusCode":"$1","Message":"$2"}</format>
                    <args>
                        <arg value="200"/>
                        <arg value="Updated Sucessfully"/>
                    </args>
                </payloadFactory>
            </then>
            <else>
                <payloadFactory description="Form Response Payload" media-type="json">
                    <format>{"StatusCode":"$1","Message":"$2"}</format>
                    <args>
                        <arg value="400"/>
                        <arg value="Unable to Created or Vin Number already exist"/>
                    </args>
                </payloadFactory>
            </else>
        </filter>
        <respond/>
        <property description="HTTPStatusCode" name="HTTP_SC" scope="axis2" type="STRING" value="200"/>
        <property description="HttpMessageType" name="messageType" scope="axis2" type="STRING" value="application/json"/>
    </outSequence>

Log

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

定格我的天空 2025-02-04 02:34:58

属性comsresponse可能是空的。

<property expression="json-eval($.ComsResponse)" name="Response" scope="default" type="STRING"/> 

JSON-EVAL语句正在寻找消息中的comsresponse元素/键。这不仅是$。只是一个字符串。

因此,目前,过滤器正在针对空字符串测试正则条件。尝试设置响应属性如下:

<property expression="json-eval($.)" name="Response" scope="default" type="STRING"/>

有关JSON-EVAL功能的更多详细信息,请检查 wso2文档。

The property ComsResponse is probably empty.

<property expression="json-eval($.ComsResponse)" name="Response" scope="default" type="STRING"/> 

The json-eval statement is looking for a ComsResponse element/key within the message. This does not exist as the result of just $. is only a string.

So currently the filter is testing the regex against an empty string. Try setting the Response property as follows:

<property expression="json-eval($.)" name="Response" scope="default" type="STRING"/>

For more details on the json-eval function check the WSO2 documentation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文