0

私はWSO2 EIの初心者で、 ESBフローで定義された API からDSSサービスを呼び出そうとすると問題が発生します。

私はこのようにしました:

1) DSSサービスに関連するagrimarketprice-dss.dbsファイルに、次の操作を行います。

<operation name="GetCommodityDetails">
    <call-query href="SelectCommodityDetails">
        <with-param name="commodity_details_id" query-param="commodity_details_id"/>
    </call-query>
</operation>

id=commodity_details_idを持つクエリを呼び出します。正常に動作し、 Try Itツールでテストしたところ、期待どおりの結果セットが得られました。

2) 次に、このESBフローで定義されたこの API を定義しました。

<?xml version="1.0" encoding="UTF-8"?>
<api context="/commodity_details" name="commodity_details" xmlns="http://ws.apache.org/ns/synapse">
    <resource methods="GET" protocol="http" uri-template="/{commodityId}">
        <inSequence>
            <property expression="get-property('uri.var.commodityId')" name="commodityId" scope="default" type="STRING"/>
            <log level="custom"/>
            <log description="commodity_details" level="custom" separator="-">
                <property name="commodity_details" value="'commodity_details START'"/>
            </log>
            <log level="custom">
                <property expression="$ctx:commodityId" name="COMMODITY ID"/>
            </log>

            <property name="messageType" scope="axis2" type="STRING" value="application/xml"/>
            <payloadFactory media-type="xml">
                <format>
                    <ds:GetCommodityDetails xmlns:ds="http://ws.wso2.org/dataservice">
                        <ds:commodity_details_id>$1</ds:commodity_details_id>
                    </ds:GetCommodityDetails>
                </format>
                <args>
                    <arg evaluator="xml" expression="$ctx:commodityId" xmlns:ds="http://ws.wso2.org/dataservice" xmlns:ns="http://org.apache.synapse/xsd"/>
                </args>
            </payloadFactory>
            <header name="Action" scope="default" value="urn:GetCommodityDetails"/>
            <call>
                <endpoint key="agrimarketprice_Endpoint"/>
            </call>
        </inSequence>
        <outSequence/>
        <faultSequence/>
    </resource>
</api>

前の ESB フローでわかるように、DSS サービスに定義された以前の操作を次のように呼び出そうとしています。

<property name="messageType" scope="axis2" type="STRING" value="application/xml"/>
<payloadFactory media-type="xml">
    <format>
        <ds:GetCommodityDetails xmlns:ds="http://ws.wso2.org/dataservice">
            <ds:commodity_details_id>$1</ds:commodity_details_id>
        </ds:GetCommodityDetails>
    </format>
    <args>
        <arg evaluator="xml" expression="$ctx:commodityId" xmlns:ds="http://ws.wso2.org/dataservice" xmlns:ns="http://org.apache.synapse/xsd"/>
    </args>
</payloadFactory>
<header name="Action" scope="default" value="urn:GetCommodityDetails"/>
<call>
    <endpoint key="agrimarketprice_Endpoint"/>
</call>

そのため、 $ctx:commodityIdで表される取得した ID を含むペイロードを作成しています(ログに記録したため、正しい値が含まれています)。次に、実行する必要がある操作の名前をヘッダーに設定します ( 「urn:GetCommodityDetails」 )。最後に、以前の DSS サービスの詳細を含むagrimarketprice_Endpointへの呼び出しを実行します。これはコンテンツです。

<?xml version="1.0" encoding="UTF-8"?>
<endpoint name="agrimarketprice_Endpoint" xmlns="http://ws.apache.org/ns/synapse">
    <address uri="http://localhost:8280/services/agrimarketprice-dss"/>
</endpoint> 

別の API の別のクエリに使用したため、このエンドポイントは正しいです (ただし、この別のクエリでは JSON ドキュメントからパラメーターを抽出しているため、ロジックが異なります)。

問題は、API を呼び出すと、Carbon ログに次のエラー メッセージが表示されることです (クエリを実行する呼び出しを実行しようとすると思います)。

TID: [-1234] [] [2017-10-03 11:55:16,574]  INFO {org.apache.synapse.mediators.builtin.LogMediator} -   {org.apache.synapse.mediators.builtin.LogMediator}
TID: [-1234] [] [2017-10-03 11:55:16,574]  INFO {org.apache.synapse.mediators.builtin.LogMediator} -  commodity_details = 'commodity_details START' {org.apache.synapse.mediators.builtin.LogMediator}
TID: [-1234] [] [2017-10-03 11:55:16,575]  INFO {org.apache.synapse.mediators.builtin.LogMediator} -  COMMODITY ID = 1 {org.apache.synapse.mediators.builtin.LogMediator}
TID: [-1234] [] [2017-10-03 11:55:16,597]  INFO {org.apache.synapse.core.axis2.TimeoutHandler} -  This engine will expire all callbacks after GLOBAL_TIMEOUT: 120 seconds, irrespective of the timeout action, after the specified or optional timeout {org.apache.synapse.core.axis2.TimeoutHandler}
TID: [-1234] [] [2017-10-03 11:55:16,637] ERROR {org.apache.axis2.engine.AxisEngine} -  The endpoint reference (EPR) for the Operation not found is /services/agrimarketprice-dss/1 and the WSA Action = null. If this EPR was previously reachable, please contact the server administrator. {org.apache.axis2.engine.AxisEngine}
org.apache.axis2.AxisFault: The endpoint reference (EPR) for the Operation not found is /services/agrimarketprice-dss/1 and the WSA Action = null. If this EPR was previously reachable, please contact the server administrator.
        at org.apache.axis2.engine.DispatchPhase.checkPostConditions(DispatchPhase.java:102)
        at org.apache.axis2.engine.Phase.invoke(Phase.java:329)
        at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:261)
        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:167)
        at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:326)
        at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:158)
        at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
TID: [-1234] [] [2017-10-03 11:55:16,642] ERROR {org.apache.synapse.transport.passthru.ServerWorker} -  Error processing GET request for : /services/agrimarketprice-dss/1 {org.apache.synapse.transport.passthru.ServerWorker}
org.apache.axis2.AxisFault: The endpoint reference (EPR) for the Operation not found is /services/agrimarketprice-dss/1 and the WSA Action = null. If this EPR was previously reachable, please contact the server administrator.
        at org.apache.axis2.engine.DispatchPhase.checkPostConditions(DispatchPhase.java:102)
        at org.apache.axis2.engine.Phase.invoke(Phase.java:329)
        at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:261)
        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:167)
        at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:326)
        at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:158)
        at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
TID: [-1] [] [2017-10-03 11:58:16,778]  INFO {org.apache.synapse.transport.passthru.SourceHandler} -  Writer null when calling informWriterError {org.apache.synapse.transport.passthru.SourceHandler}
TID: [-1] [] [2017-10-03 11:58:16,780]  WARN {org.apache.synapse.transport.passthru.SourceHandler} -  Connection time out after request is read: http-incoming-6 Socket Timeout : 180000 Remote Address : /168.202.253.227:62418 {org.apache.synapse.transport.passthru.SourceHandler}

このエラーは、次のログ情報に関連していると思われます。

The endpoint reference (EPR) for the Operation not found is /services/agrimarketprice-dss/1 and the WSA Action = null

渡された id (1) をagrimarketprice-dss (サービス名) に追加しようとしているようで、操作 ( GetCommodityDetailsであり、ヘッダーで指定したもの) を無視しています。

では、何が問題なのですか?私は何が欠けていますか?このエラーを修正するにはどうすればよいですか?

EDIT-1 : 私は別の方法を試しました: API は、URL パスからではなく、リクエスト内の次のような JSON ドキュメントから、commodity_idを取得します。

{
"commodity_id": 1
}

したがって、このように API を変更すると、正常に動作し、クエリが正しく実行されます (ただし、URL から商品 IDを取得し、それをクエリ パラメーターとして使用する必要があります (回避策にすぎない可能性があります)。

<?xml version="1.0" encoding="UTF-8"?>
<api context="/commodity_details" name="commodity_details" xmlns="http://ws.apache.org/ns/synapse">
    <resource methods="POST" protocol="http" uri-template="/">
        <inSequence>
            <log level="full"/>
            <log level="custom">
                <property expression="json-eval($.commodity_id)" name="Commodity ID"/>
            </log>
            <property expression="json-eval($.commodity_id)" name="CommodityId" scope="default" type="STRING"/>
            <property name="messageType" scope="axis2" type="STRING" value="application/xml"/>
            <payloadFactory media-type="xml">
                <format>
                    <ds:GetCommodityDetails xmlns:ds="http://ws.wso2.org/dataservice">
                        <ds:commodity_details_id>$1</ds:commodity_details_id>
                    </ds:GetCommodityDetails>
                </format>
                <args>
                    <arg evaluator="json" expression="$.commodity_id"/>
                </args>
            </payloadFactory>
            <header name="Action" scope="default" value="urn:GetCommodityDetails"/>
            <call>
                <endpoint key="agrimarketprice_Endpoint"/>
            </call>

            <send/>
        </inSequence>
        <outSequence>
            <send/>
        </outSequence>
        <faultSequence/>
    </resource>
</api>

このようにして、DSS サービスが正しく呼び出され、クエリが実行され、API が期待される出力をクライアントに送り返します。

しかし、POST リクエストで JSON ドキュメントから ID を取得すると問題なく動作するのに、URL から取得するとうまくいかないのはなぜでしょうか?

4

1 に答える 1