Issue with WSO2 ESB OutSequence



我正面临REST API中序列外的一些问题。我的用例是,我将接收json请求,调用一个服务,如果成功,则调用第二个服务。现在我跳过了对第一服务响应的检查。在inSequence中有一个端点,在outSequence中有另一个端点。问题是在outSequence中,它进入了无限循环。

请让我知道我错过了什么。

<?xml version="1.0" encoding="UTF-8"?>
<api context = "/content_filter" hostname = "localhost" name = "Content_Filter" port = "8282" xmlns = "http://ws.apache.org/ns/synapse">
    <resource methods = "POST" protocol = "http" uri-template = "/test/content_filter">
        <inSequence>
            <property action = "remove" description = "REST_URL_POSTFIX" name = "REST_URL_POSTFIX" scope = "axis2"/>
            <payloadFactory description = "payLoad-modifier" media-type = "json">
                <format>{"SvcValidateRq": {"UserAccountInfo": {"UserID": "$1", "Password": "$2"}}}</format>
                <args>
                    <arg evaluator = "json" expression = "$.UserAccountInfo.UserID"/>
                    <arg evaluator = "json" expression = "$.UserAccountInfo.Password"/>
                </args>
            </payloadFactory>
            <property description = "message_type" name = "messageType" scope = "default" type = "STRING" value = "application/json"/>
            <property description = "content_type" name = "ContentType" scope = "axis2" type = "STRING" value = "application/json"/>
            <send>
                <endpoint>
                    <address format = "rest" trace = "disable" uri = "http://10.202.17.86:8085/UserInfo/rest/v1/login"/>
                </endpoint>
            </send>
        </inSequence>
        <outSequence>
            <log description = "output_logger" level = "full"/>
            <property description = "output_content" name = "ContentType" scope = "axis2" type = "STRING" value = "application/json"/>
            <payloadFactory description = "payload" media-type = "json">
                <format>{"SvcValidateRq": {"UserAccountInfo": {"UserID": "f987d3b2-f5bf-4cc7-83e2-c08322dfaac0", "Password": "23776BD42FEB4F06812F30A01FC7F6FD"}}}</format>
                <args/>
            </payloadFactory>
            <header description = "TimeStamp" name = "com.ugo.wallet.envelope.TimeStamp" scope = "transport" value = "7672387"/>
            <header description = "CorrelationID" name = "com.ugo.wallet.envelope.CorrelationID" scope = "transport" value = "9384982948"/>
            <header description = "TraceabilityID" name = "com.ugo.wallet.envelope.TraceabilityID" scope = "transport" value = "394892349"/>
            <send>
                <endpoint>
                    <address format = "rest" trace = "disable" uri = "http://10.202.17.86:8085/UserInfo/rest/v1/login"/>
                </endpoint>
            </send>
        </outSequence>
        <faultSequence>
            <log description = "error_log" level = "full"/>
            <property description = "error_content" name = "ContentType" scope = "axis2" type = "STRING" value = "application/json"/>
            <send/>
        </faultSequence>
    </resource>
</api>

下面是输出堆栈跟踪。

To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:77505542-4950-406c-95ff-b75541f03683, Direction: response, Payload: {"SvcValidateRs":{"Status":{"StatusCode":2,"Severity":"Error","StatusDesc":"Error","AdditionalStatus":[{"StatusCode":2036,"Severity":"Error","StatusDesc":"Invalid LoginID/Password","RefInfo":[{"KeyName":"FAILURE_INFO","KeyValue":["LoginID/Password is invalid."]},{"KeyName":"ORIGIN","KeyValue":["UserInfo.REST"]}]}]}}} {org.apache.synapse.mediators.builtin.LogMediator}
To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:cdfc7f8b-0517-407f-a081-5196610853c0, Direction: response, Payload: {"SvcValidateRs":{"Status":{"StatusCode":2,"Severity":"Error","StatusDesc":"Error","AdditionalStatus":[{"StatusCode":2036,"Severity":"Error","StatusDesc":"Invalid LoginID/Password","RefInfo":[{"KeyName":"FAILURE_INFO","KeyValue":["LoginID/Password is invalid."]},{"KeyName":"ORIGIN","KeyValue":["UserInfo.REST"]}]}]}}} {org.apache.synapse.mediators.builtin.LogMediator}
To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:049dd134-b29d-4abe-9653-0f3501a76e0a, Direction: response, Payload: {"SvcValidateRs":{"Status":{"StatusCode":2,"Severity":"Error","StatusDesc":"Error","AdditionalStatus":[{"StatusCode":2036,"Severity":"Error","StatusDesc":"Invalid LoginID/Password","RefInfo":[{"KeyName":"FAILURE_INFO","KeyValue":["LoginID/Password is invalid."]},{"KeyName":"ORIGIN","KeyValue":["UserInfo.REST"]}]}]}}} {org.apache.synapse.mediators.builtin.LogMediator}
To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:5156f9e8-5d6b-432b-b016-59175583b663, Direction: response, Payload: {"SvcValidateRs":{"Status":{"StatusCode":2,"Severity":"Error","StatusDesc":"Error","AdditionalStatus":[{"StatusCode":2036,"Severity":"Error","StatusDesc":"Invalid LoginID/Password","RefInfo":[{"KeyName":"FAILURE_INFO","KeyValue":["LoginID/Password is invalid."]},{"KeyName":"ORIGIN","KeyValue":["UserInfo.REST"]}]}]}}} {org.apache.synapse.mediators.builtin.LogMediator}

您需要从out序列中删除以下内容。在ESB中,当接收到响应时,它将触发结果序列,因此您看到的是无限循环。可以在序列中使用调用中介而不是发送中介来避免这种情况。

<send>
<endpoint>
<address format = "rest" trace = "disable" uri = http://10.202.17.86:8085/UserInfo/rest/v1/login"/>
</endpoint>
</send>

下面是一篇很好的文章来涵盖你的用例。

http://wso2.com/library/articles/2014/02/service-orchestration-with-wso2-esb/

感谢您的回复。我不确定,但是当我使用Call mediator时,服务调用不会发生。但是Send中介可以工作。我能够解决这个问题,无论是在inSequence和outSequence相同的url。我更改了outSequence的URL,现在工作正常

最新更新