2013-12-11 132 views
1

我已经暴露在WSO2 ESB使用<api> REST服务。但答复并未到来。 REST服务是用Apache Wink编写的。WSO2 ESB - REST API - 响应不来

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日志

[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

我觉得你的端点地址是错误的,看起来像你有重复两次打招呼。因为您在代理名称中也有hello,这也会附加到URL。

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

你也可以在单独的浏览器调用“URI + URL映射”验证

我已经表明样品API下面对我的作品后端的作品,你应该叫您的API作为下面和日志将打印如下。

网址拨打:http://localhost:8280/TestAPI/customerservice/customers/123

INFO - LogMediator为:/ TestAPI /的CustomerService /客户/ 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> 
+0

的 “http://本地主机:8080/HelloService的/ REST /测试/你好” 是实际的RESTful Web服务实现。当请求发送到“http:// localhost:8280/hello/name”时,它是否充当代理并将请求转发给实际实现? – user3049576

+0

好,你的情况proxy会转发到您的地址请求(HTTP://本地主机:8080/HelloService的/ REST /测试/你好/ ),这是http://本地主机:8080/HelloService的/ REST /测试/你好/ name,因此请查看您是否在浏览器中获得此URL的响应。 – jayalalk

+0

此外,如果上述后端网址运作正常,请从API定义中删除主机名和端口,这是这里的问题。使用像我的示例,让我知道你的问题是否由此解决。它的工作原理是 – jayalalk