12
返回列表 发新帖
楼主: jieforest

RavenDB文档数据库的HTTP API介绍

[复制链接]
论坛徽章:
277
马上加薪
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有车
日期:2014-02-19 11:55:14马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11版主9段
日期:2012-11-25 02:21:03ITPUB年度最佳版主
日期:2014-02-19 10:05:27现任管理团队成员
日期:2011-05-07 01:45:08
11#
 楼主| 发表于 2014-3-13 09:04 | 只看该作者
Time for action – performing a GET request

You will learn to create a GET request using the RESTClient tool we have downloaded in the previous section to retrieve the document with the ID = Orders/A655302 from the Orders database and view it. (We created the Orders database in Chapter 2, RavenDB Management Studio.)

1)If it is not already open, double-click on the RESTClient tool's JAR file in order to launch it.

2)Click on the Method tab and select the GET HTTP method.

3)In the HTTP Request section, enter this URL: http://localhost:8080/databases/orders/docs/orders/a655302.

使用道具 举报

回复
论坛徽章:
277
马上加薪
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有车
日期:2014-02-19 11:55:14马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11版主9段
日期:2012-11-25 02:21:03ITPUB年度最佳版主
日期:2014-02-19 10:05:27现任管理团队成员
日期:2011-05-07 01:45:08
12#
 楼主| 发表于 2014-3-13 09:05 | 只看该作者
Note

To perform this GET request, we don't need to change any of the Header or the Body, or other parameters.

4)Click on the green Go! button to send your first request to the server.

What just happened?

You just created your first GET request to retrieve the order document with the ID Orders/A655302 from the Orders database directly by using the RavenDB HTTP API.

Let's have a look at the server response and analyze it. The first thing that we need to check when we receive an HTTP response from the server is the status code. In case of a GET request, receiving an HTTP/1.1 200 OK code indicates that the request has succeeded. Otherwise there is an error and the server has not received, understood, or has not accepted the request.

使用道具 举报

回复
论坛徽章:
277
马上加薪
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有车
日期:2014-02-19 11:55:14马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11版主9段
日期:2012-11-25 02:21:03ITPUB年度最佳版主
日期:2014-02-19 10:05:27现任管理团队成员
日期:2011-05-07 01:45:08
13#
 楼主| 发表于 2014-3-13 09:06 | 只看该作者
Select the Headers tab in the HTTP Response section and look to the header's data which came with the server response. We can see the RavenDB metadata Raven-Entity-Name from which the document has been retrieved.

Click on the Body tab to show the response body and you will see what the server sent back is a JSON document which is the actual JSON data document stored on the RavenDB server (which you can see using the Management Studio).

You just created your first GET request to retrieve the order document with the ID Orders/A655302 from the Orders database directly by using the RavenDB HTTP API.

Let's have a look at the server response and analyze it. The first thing that we need to check when we receive an HTTP response from the server is the status code. In case of a GET request, receiving an HTTP/1.1 200 OK code indicates that the request has succeeded. Otherwise there is an error and the server has not received, understood, or has not accepted the request.

使用道具 举报

回复
论坛徽章:
277
马上加薪
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有车
日期:2014-02-19 11:55:14马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11版主9段
日期:2012-11-25 02:21:03ITPUB年度最佳版主
日期:2014-02-19 10:05:27现任管理团队成员
日期:2011-05-07 01:45:08
14#
 楼主| 发表于 2014-3-13 09:06 | 只看该作者
Select the Headers tab in the HTTP Response section and look to the header's data which came with the server response. We can see the RavenDB metadata Raven-Entity-Name from which the document has been retrieved.

Click on the Body tab to show the response body and you will see what the server sent back is a JSON document which is the actual JSON data document stored on the RavenDB server (which you can see using the Management Studio).

使用道具 举报

回复
论坛徽章:
277
马上加薪
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有车
日期:2014-02-19 11:55:14马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11版主9段
日期:2012-11-25 02:21:03ITPUB年度最佳版主
日期:2014-02-19 10:05:27现任管理团队成员
日期:2011-05-07 01:45:08
15#
 楼主| 发表于 2014-3-13 09:06 | 只看该作者
You see how simple it was to get a document from RavenDB server using the HTTP API. We can basically get any document from the RavenDB server using the same approach.

Have a go hero – retrieving the databases list

You now know how to get any document from the RavenDB server using the HTTP API. Open the RESTClient tool and by using a GET HTTP method retrieve the databases' list from the server and compare it with the list you see when you open the Management Studio.

Need a hint? Use the RavenDB regular URL and the databases endpoint.

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表