WSO2 ESB OutSequence问题

时间:2016-09-08 08:23:03

标签: wso2 wso2esb

我在REST API中面临一些out-sequence的问题。我的用例是我将收到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}

2 个答案:

答案 0 :(得分:0)

您需要从输出序列中删除以下内容。在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/

答案 1 :(得分:0)

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