我已经在wso2esb中使用<api>
公开了一个REST服务。但没有得到回应。REST服务是用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日志
[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
我认为你的端点地址是错误的,看起来你已经重复了两次hello。因为您在代理名称中也有hello,它将附加到URL中。
尝试<address uri="http://localhost:8080/HelloService/rest/test"/>
此外,您可以通过在单独的浏览器中调用"uri+url映射"来验证您的后端工作
我在下面展示了API的例子,你应该调用你的API如下,日志将打印如下。
要调用的URL:http://localhost:8280/TestAPI/customerservice/customers/123
信息-LogMediator收件人:/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>