1
<resource methods="GET" uri-template="/getTypeCodes" faultSequence="service_error_handler_">
  <inSequence>
     <log level="custom">
        <property name="CommonService" value="*************getTypeCodes called**************"/>
        <property name="Request Payload" expression="get-property('JSON_OBJECT')"/>
     </log>
     <property name="HTTP_METHOD" value="GET" scope="axis2" type="STRING"/>
     <property name="messageType" value="application/json" scope="axis2" type="STRING"/>
     <sequence key="oauthMediationService"/>
     <property name="uri.var.servicename" value="commonservice"/>
     <send>
          <endpoint>
           <address uri="http://localhost:8080/rest/commonservice/getTypeCodes" format="rest"/>
        </endpoint>
     </send>
     <log level="custom">
        <property name="getTypeCodeResponse" expression="$body"/>
     </log>
  </inSequence>
  <outSequence>
     <send/>
  </outSequence>

上記の残りの構成例から、エンドポイントでサービスを呼び出しています。エンドポイントを呼び出した後、応答を取得し、その応答を条件に基づいて別のエンドポイントに送信する必要があります。

4

2 に答える 2

2

次の構成を使用して、サービスをリセットし、応答を取得するために呼び出すことができます。以下のサンプルでは、​​HTTP エンドポイントを使用しています

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="peoplePutProxy"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
    <target>
        <inSequence>
            <property name="HTTP_METHOD" value="GET" scope="axis2"/>
            <property name="messageType"
                      value="application/x-www-form-urlencoded"
                      scope="axis2"/>
            <send>
                <endpoint>
                    <http method="post"
                          uri-template="http://localhost:8080/rest/api/people?email={uri.var.email}&firstName={uri.var.fname}&lastName={uri.var.lname}"/>
                    <property name="uri.var.fname" value="dhar"/>
                    <property name="uri.var.email" value="kasun@gmail.com"/>
                    <property name="uri.var.lname" value="kasun"/>
                </endpoint>
            </send>
        </inSequence>
        <outSequence>
            <log level="full"/>
            <property name="messageType" value="text/xml" scope="axis2"/>
            <send/>
        </outSequence>
    </target>
    <description/>
</proxy> 

HTTP エンドポイントは、RESTful サービス呼び出しの最終 URI を動的に入力できる URI テンプレートをユーザーが指定できる場所です。また、ユーザーは送信リクエストの HTTP メソッドを操作できます。http エンドポイントの詳細については、[1] を参照してください。

[1]。http://docs.wso2.org/display/ESB470/HTTP+エンドポイント

于 2013-09-04T18:08:57.040 に答える
-1

あなたの要件は「サービスチェーン」と呼ばれます。このブログ投稿では、WSO2 ESB でサービス チェーンを実現する方法について説明します。そのブログの冒頭にリンクされている他の記事を読んで、理解を深めてください。これらは、サービス チェーンの完全な例を提供します。

基本的に、次のように、送信メディエーターで応答の受信者としてシーケンスを指定できます。

 <send receive="RespSequence">
      <endpoint>
       <address uri="http://localhost:8080/rest/commonservice/getTypeCodes" format="rest"/>
    </endpoint>
 </send>

この場合、エンドポイントの呼び出しからの応答は に送信されRespSequenceます。したがって、そのシーケンスで他のエンドポイントを指定できます。詳細については、 Send Mediator のドキュメントを参照してください。Switch Mediatorを使用して条件を確認します。

于 2013-09-04T12:06:10.650 に答える