[英]How to Integrate RESTful service in the WSO2 ESB
I am trying to create an integration layer through the WSO2 ESB (RESTful API Service Integration). 我正在尝试通过WSO2 ESB(RESTful API服务集成)创建一个集成层。
Endpoint - http://www.thomas-bayer.com/ 端点-http: //www.thomas-bayer.com/
Context - /sqlrest 上下文-/ sqlrest
and 和
URI-template - /CUSTOMER/3 URI模板-/ CUSTOMER / 3
( API Endpoint - www.thomas-bayer.com/sqlrest/CUSTOMER/3 ) (API端点-www.thomas-bayer.com/sqlrest/CUSTOMER/3)
After everything when I'm trying to invoke the api request with ( http://localhost:8280:/sqlrest/CUSTOMER/3 ) 在尝试使用( http:// localhost:8280:/ sqlrest / CUSTOMER / 3 )调用api请求时,执行所有操作
I'm getting the response as full HTML with 404 error code rather than the XML Data. 我得到的响应是带有404错误代码的完整HTML而不是XML数据。
you can use this API in WSO2 ESB: 您可以在WSO2 ESB中使用此API:
<?xml version="1.0" encoding="UTF-8"?>
<api xmlns="http://ws.apache.org/ns/synapse"
name="sqlrestAPI"
context="/sqlrest">
<resource methods="GET" protocol="http" uri-template="/CUSTOMER/{id}">
<inSequence>
<log level="full"/>
<send>
<endpoint>
<http method="GET"
uri-template="http://www.thomas-bayer.com/sqlrest/CUSTOMER/{uri.var.id}"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</resource>
</api>
And call it with (OFFSET = 3 in my case): 并调用它(在我的情况下,OFFSET = 3):
curl -v http://localhost:8283/sqlrest/CUSTOMER/3
The response: 响应:
* About to connect() to localhost port 8283 (#0)
* Trying 127.0.0.1...
* connected
* Connected to localhost (127.0.0.1) port 8283 (#0)
> GET /sqlrest/CUSTOMER/3 HTTP/1.1
> User-Agent: curl/7.25.0 (i386-pc-win32) libcurl/7.25.0 OpenSSL/0.9.8u zlib/1.2.6 libssh2/1.4.0
> Host: localhost:8283
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: application/xml
< Date: Thu, 26 Jan 2017 16:40:08 GMT
< Transfer-Encoding: chunked
<
<?xml version="1.0"?><CUSTOMER xmlns:xlink="http://www.w3.org/1999/xlink">
<ID>3</ID>
<FIRSTNAME>Michael</FIRSTNAME>
<LASTNAME>Clancy</LASTNAME>
<STREET>542 Upland Pl.</STREET>
<CITY>San Francisco</CITY>
</CUSTOMER>* Connection #0 to host localhost left intact
* Closing connection #0
The context you provide does not need to be anything from the actual endpoint URL. 您提供的上下文不需要来自实际端点URL。
For example, you can define context as myapi
. 例如,您可以将上下文定义为myapi
。 Then you have 2 options. 然后,您有2个选择。
Option 1: 选项1:
Configure endpoint as http://www.thomas-bayer.com/
将端点配置为http://www.thomas-bayer.com/
Then you can call your API as http://localhost:8280/myapi/sqlrest/CUSTOMER/3
然后您可以将您的API调用为http://localhost:8280/myapi/sqlrest/CUSTOMER/3
Option 2: 选项2:
Configure endpoint as http://www.thomas-bayer.com/sqlrest/
将端点配置为http://www.thomas-bayer.com/sqlrest/
Then you can call your API as http://localhost:8280/myapi/CUSTOMER/3
然后可以将您的API调用为http://localhost:8280/myapi/CUSTOMER/3
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.