WSO2 ESB - REST API - Response Does Not Come

蓝咒 提交于 2020-02-05 05:38:05

问题


I have exposed a REST service using <api> in wso2 esb. But the response does not come. REST service is written in Apache Wink.

API

<api name="API_2" context="/hello" hostname="localhost" port="8080">
  <resource url-mapping="/name" methods="GET">
    <inSequence>    
      <log level="full"/>
      <property name="messageType" value="text/plain" scope="transport" type="STRING"/>             
      <send>
        <endpoint>                              
          <address uri="http://localhost:8080/HelloService/rest/test/hello"/>
        </endpoint>
      </send>
    </inSequence>
    <outSequence>
      <log level="full"/>
      <send/>
    </outSequence>
  </resource>   
</api>

esb log

[2013-12-11 12:28:24,643]  INFO - API Initializing API: API_2
[2013-12-11 12:28:35,467]  INFO - LogMediator To: /hello/name, MessageID: urn:uuid:52d2ddf1-301e-42e0-ac9d-ac4a57ac8c72, Direction: request

回答1:


I think your endpoint address is wrong , look like you have repeat hello twice. since you have hello in proxy name also which will append to URL.

try <address uri="http://localhost:8080/HelloService/rest/test"/>

Also You can verify your backend works by calling "uri + url-mapping" in separate browser

I have shown sample API works for me below, you should have called your API as below and log will print as below.

URL to call: http://localhost:8280/TestAPI/customerservice/customers/123

INFO - LogMediator To: /TestAPI/customerservice/customers/123

    <api xmlns="http://ws.apache.org/ns/synapse" name="TestAPI" context="/TestAPI">
   <resource methods="GET" url-mapping="/customerservice/customers/123">
      <inSequence>
         <log/>
         <send>
            <endpoint>
               <address uri="http://localhost:9764/jaxrs_basic/services/customers"/>
            </endpoint>
         </send>
      </inSequence>
      <outSequence>
         <log/>
         <send/>
      </outSequence>
   </resource>
</api>


来源:https://stackoverflow.com/questions/20512677/wso2-esb-rest-api-response-does-not-come

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!