首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在RESTful ESB中集成WSO2服务

如何在RESTful ESB中集成WSO2服务
EN

Stack Overflow用户
提问于 2017-01-26 07:18:49
回答 2查看 677关注 0票数 1

我试图通过WSO2 ESB (RESTful )创建一个集成层。

端点- http://www.thomas-bayer.com/

上下文- /sqlrest

URI-模板- /CUSTOMER/3

( API Endpoint -www.thoms-bayer.com/sqlrest/CUSTOMER/3)

之后,当我试图用( http://localhost:8280:/sqlrest/CUSTOMER/3 )调用api请求时

我得到的响应是带有404错误代码的完整HTML,而不是XML数据。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-01-26 16:42:14

您可以在WSO2 ESB中使用此API:

代码语言:javascript
复制
<?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>

并调用它(在我的例子中,偏移量=3):

代码语言:javascript
复制
curl -v http://localhost:8283/sqlrest/CUSTOMER/3

答复:

代码语言:javascript
复制
* 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
票数 2
EN

Stack Overflow用户

发布于 2017-01-26 16:31:59

您提供的上下文不需要是来自实际端点URL的任何内容。

例如,可以将上下文定义为myapi。那么你有两个选择。

选项1:

将端点配置为http://www.thomas-bayer.com/

然后,您可以将API称为http://localhost:8280/myapi/sqlrest/CUSTOMER/3

备选方案2:

将端点配置为http://www.thomas-bayer.com/sqlrest/

然后,您可以将API称为http://localhost:8280/myapi/CUSTOMER/3

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41868491

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档