【问题标题】:How to get the response of a rest call inside the api in WSO2 ESB?如何在 WSO2 ESB 的 api 中获取休息调用的响应?
【发布时间】:2013-09-27 15:34:41
【问题描述】:

我正在调用下面播种的其余服务

<resource methods="GET" url-mapping="/getallpayments" faultSequence="error_handler_">
  <inSequence>
     <log level="custom">
        <property name="CashreceiptsService" value="**************Entered into getallpayments*************"/>
        <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"/>
     <oauthService remoteServiceUrl="https://localhost:9443/services/OAuth2TokenValidationService/" username="admin" password="admin"/>
     <log level="custom">
        <property name="CashreceiptService" value="^^^^^^^^^^^^OAUTH COMPLETED^^^^^^^^^^^^"/>
        <property name="User Name******" expression="get-property('username')"/>
     </log>
     <send>
        <endpoint>
           <http format="rest" method="GET" uri-template="http://localhost:8080/rest/commonService/getallpayments"/>
        </endpoint>
     </send>

     <drop/>
  </inSequence>

它会给出以下响应

[{"typeId":1,"name":"Entity_Type","value":"EMPLOYER","description":"Employer","createdDate":"08/12/2013","tenantId":0,"hasPhiFields":false},{"typeId":2,"name":"Entity_Type","value":"BROKER","description":"Broker","createdDate":"08/12/2013","tenantId":0,"hasPhiFields":false}]

我能够在 UI 中获得上述响应。 但是我需要 Api 中的“typeId”响应,并且我需要获取该 typeId 并将其作为输入参数传递给另一个服务,该服务将对 UI 给出最终响应。 现在我正在使用服务链来实现。

主要问题是如何获取一个服务的响应并作为输入参数传递给另一个服务?请建议我,我是 WSO2 ESB 的新手。

以及如何获取用户发送的 POST 数据?

【问题讨论】:

    标签: wso2esb


    【解决方案1】:

    您可以获取 out 序列中的值,或者任何其他序列以从他们那里获取响应,您可以发送到另一个端点或代理或任何端点 在您的情况下,您可以按顺序或任何其他顺序获取值,您需要采用这样的特殊对象

    <property xmlns:f="http://ws.wso2.org/dataservice" xmlns:ns="http://org.apache.synapse/xsd" name="typeid" expression="//f:typeid/text" scope="default" type="STRING"/>
    

    或者你根据你的端点定义

    <send receive="someothersequencename">
            <endpoint>
               <http format="rest" method="GET" uri-template="http://localhost:8080/rest/commonService/getallpayments"/>
            </endpoint>
         </send>
    

    然后你会得到这个序列中的所有响应

    【讨论】:

      猜你喜欢
      • 2015-02-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-06
      相关资源
      最近更新 更多