paulwong

#

REST client 基于浏览器的测试工具

  以前在开发webservice服务,都是自己基于HTTP协议,自己写一个测试程序来进行测试,最近在研究RestFul,对以前webservice服务进行了重构,总结了不少经验,今天就给大家介绍下几款Rest Client的测试工具。

REST介绍

  所谓REST,是Representational State Transfer,这个词汇的中文翻译很不统一,而且很晦涩,有叫“具象状态传输”,有叫“表象化状态转变”,等等。

  REST风格的Web服务,是通过一个简洁清晰的URI来提供资源链接,客户端通过对URI发送HTTP请求获得这些资源,而获取和处理资源的过程让客户端应用的状态发生改变(不像那些远程过程调用那么直接地发生改变)。

  常用的对资源进行CRUD(Create, Read, Update 和 Delete)的四种HTTP方法分别是POST, GET, PUT, DELETE。

基于浏览器的Rest Client工具

  在chrome或者firefox浏览器都有很多插件,我一般都是使用chrome浏览器,在chrome的webstore中可以搜索到自己想要的插件。这里就讲讲Advance REST Client,Postman-REST Client,DEV HTTP CLIENT,Simple REST Client,火狐下的RESTClient插件

Advanced REST client

  网页开发者辅助程序来创建和测试自定义HTTP请求。它是一款非常强大,使用简单的客户端测试工具,得到了程序员的好评。每周超过50k的开发者使用此应用程序。如此多的人是不会错的! 

支持的功能

  1. Make a HTTP request (via XmlHttpRequest level 2)
  2. Debug socket (via web socket API).
  3. JSON response viewer
  4. XML response viewer
  5. set custom headers - even does not supported by XmlHttpRequest object
  6. help with filling HTTP headers (hint + code completion)
  7. add headers list as raw data or via form
  8. construct POST or PUT body via raw input, form or send file(s) with request
  9. set custom form encoding
  10. remember latest request (save current form state and restore on load)
  11. save (Ctrl+S) and open (Ctrl+O) saved request forms
  12. history support
  13. data import/export

Postman -REST client

  Postman可以帮助你更有效的针对API工作。Postman是一个scratch-your-own-itch项目。它需要的是开发者有效的在项目中创建APIS,能够对API测试进行收藏保留。 

支持功能

  1. HTTP requests 支持文件上传
  2. 格式化API响应的JSON and XML
  3. 打开 responses 的HTML文件在一个新窗口展示
  4. 支持REST准则的超媒体应用状态的引擎- HATEOS
  5. 图像预览
  6. Request history
  7. 基本oauth 1.0助手
  8. Autocomplete for URL and header values
  9. 可以在URL参数中使用 key/value编辑添加参数或header值
  10. 使用环境变量容易转移之间设置。可用于测试,生产,分期或本地设置。
  11. 使用全局变量的值是在整个 APIs
  12. 使用快速查找功能预览变量和它们的值使用状况
  13. 键盘快捷方式,最大限度地提高您的生产力

Simple REST Client

  Simple REST Client插件,提供了一个简单的表单进行各种HTTP操作,并可以看到返回的信息。构建自定义HTTP请求直接测试您的网络服务。 

Firefox下的RESTClient

  FirefoxRESTClient的插件,这款插件由国人开发,功能上支持Basic和OAuth的登录header发送,并且对于返回的XML数据还可以高亮显示

Linux常用的工具CURL

  CURL是一个很强大的支持各种协议的文件传输工具,用它来进行RESTful Web Services的测试简直是小菜一碟。

CURL的命令参数非常多,一般用于RESTful Web Services测试要用到下面四种参数:

  • -d/–data :POST数据内容
  • -X/–request :指定请求的方法(使用-d时就自动设为POST了)
  • -H/–header  :设定header信息
  • -I/–head:只显示返回的HTTP头信息

Java GUI rest-client

  这是一个用Java写的测试小工具,项目主页上提到它有命令行和GUI两种版本。为了方便操作我们选择GUI版本来看看。既然是一款软件,显然就比刚才介绍的浏览器插件功能更加强大。它支持应答正文的JSON和XML缩排和高亮,还可以一键搭建一个RESTful服务端,另外还提供了单元测试的功能。

格式化JSON数据
https://chrome.google.com/webstore/detail/jsonview-jsonviewer-json/hdmbdioamgdkppmocchpkjhbpfmpjiei

posted @ 2014-04-19 18:45 paulwong 阅读(41425) | 评论 (1)编辑 收藏

Java EE 应用开发平台 Koala

Koala (考拉) 是一款应用在 Java EE 企业级应用开发领域,用于帮助架构师简化系统设计,降低框架耦合度,提高系统灵活性,提供开发工程师工作效率,降低成本的平台工具。

为什么使用 Koala:

  • 开源免费的开发平台,允许你任意修改源码并扩展功能
  • 以DDD领域驱动思想为核心,抛弃传统的以数据库为中心的四层编码模型
  • 丰富的基础组件支持,包括:国际化、异常、缓存等
  • 向导式的搭建项目过程,支持各种技术选择,JPA,Mybstis,SpringMVC,struts2MVC等
  • 向导式的数据库到实体的生成过程
  • 向导式的实体生成CURD功能
  • 向导式的服务发布一键无缝发布成war、EJB、webservice(SOAP/REST) 多种服务形式
  • 基于RBAC3模型的权限子系统
  • 监控子系统轻松协助你监控URL,方法,数据库,内存等状态
  • 使用通用查询子系统轻松定制完成查询功能
  • 基于IP过滤,用户名验证及方法权限控制的WS安全子系统
  • 基于JBPM5的流程子系统

http://wiki.openkoala.org/pages/viewpage.action?pageId=3932164

posted @ 2014-04-17 09:18 paulwong 阅读(710) | 评论 (0)编辑 收藏

微信公众平台开发资源

http://blog.csdn.net/lyq8479/article/category/1366622/2

微信JAVA工具集
https://github.com/chanjarster/weixin-java-tools






posted @ 2014-04-09 21:57 paulwong 阅读(354) | 评论 (0)编辑 收藏

javaee7-samples

http://git.oschina.net/ld/javaee7-samples

posted @ 2014-04-06 08:33 paulwong 阅读(570) | 评论 (0)编辑 收藏

也谈基于Web的含工作流项目的一般开发流程(转)

该项目包含的通用模块代码等我有时间一并剥离贡献出来(基于WebSocket的通知引擎,工作流整合模块,自定义表单(详见这里),基于RBAC权限设计),最近太忙了,Web项目有一段时间没碰,有点生疏的感觉,主要在忙GQT项目,一套基于桌面开发的框架,详见这里,写代码写的有点手酸的感觉。  

基于Web的含工作流的项目看起来并不如想象的那么简单,主要需求:
  1. 灵活定制工作流,并跟踪流程进度;
  2. 每个Order含有历史轨迹记录,可在历史中查看;
  3. 工作流的Action灵活,认领任务不一定非要先提取表单,因为很多节点都只有几个动作,直接按钮操作即可;
  4. 待办事宜列表在不刷新页面情况下也能变动;
项目要求:
  1. 操作简单高效;
  2. 权限细节到按钮级别;
  3. 并发数少,不超过3000个在线用户;
主要可能使用到技术:
  1. 工作流引擎,我这里选用Activiti5,很灵活好用;
  2. 权限使用Spring Security,基于标签式管理权限很方便;
  3. 通知引擎使用WebSocket,基于Flash实时通信,基于socket.io;
  4. 权限粒度基于经典的RBAC;
  5. 总体框架Spring MVC+Mybatis;
实现的WebSocket的总体思路:
  1. WebSocket Server独立于Web项目,Web Server与WebSocket Server之间的局域网通信基于简单的Socket通信,这样这个组件可以完全解耦和通用;
  2. 当Web项目要Push消息到Client时,通过Web Server的Socket Client向WebSocket Server的Socker Server发送消息,然后WebSocket Server收到消息后解码,广播到所有浏览器;
我们实现的事件通知非常简单,设定全局变量并让浏览器侦听:
var G_WebSocket=false; 
var EVENT_ORDER_CHANGE_STATUS = "orderChange";
var EVENT_ORDER_CHANGE_AMOUNT = "amountChange";
var EVENT_ORDER_CHANGE_REFUND = "refundChange";
WebSocket.init = function(callbackFunc){
socket = io.connect(connUrl, connOptions);
socket.on('connect', function() {
G_WebSocket=true;
callbackFunc("connect",null);
});
socket.on('disconnect', function() {
G_WebSocket=false;
callbackFunc("disconnect",null);
});
socket.on('clientQuit', function(obj){
G_WebSocket=false;
callbackFunc("clientQuit",obj);
});
socket.on('broadcast', function(obj) {
callbackFunc("broadcast",obj);
});
};
 
在需要侦听WebSocket接受Web Server推送消息的地方加上一个函数即可:
	WebSocket.init(function(command,jsonObj){ 
if(command=="broadcast"){
if(jsonObj.e == EVENT_ORDER_CHANGE_STATUS){
//TODO:write your code here
}else if(jsonObj.e == EVENT_ORDER_CHANGE_AMOUNT){
//TODO:write your code here
}else if(jsonObj.e == EVENT_ORDER_CHANGE_REFUND){
//TODO:write your code here
}
}
});

这样的结构要扩展推送服务很简单,比如按频道推送等,都可以很容易的扩展。
再看看看工作流,我们实现了activiti通用的申请提交任务流程和自定义表单功能,提取跟踪流程图功能等,这样你要设计一个新流程也变得非常简单,只需要在eclipse里划上工作流图,在后台发布,然后通过SpringMVC的RestAPI启动实例流程,申领完成任务等,如下图:




流程走到了分支的两个节点上,这样对后续新增的工作流提供了极大的遍历。

最后说说Spring Security,基于RBAC的权限体系搭建好后(可以用在任何管理系统中),要在页面中访问一个资源,首先判断一下是否有权限,如下HTML:


<sec:authorize ifAllGranted="r_pd"> 
<a href="#">resource access here</a>
</sec:authorize>

 

<sec:authorize url="/XXX/XXX/XXX.html"> 
<a href="XXX/XXX/XXX.html'">
<span>XXX功能</span>
</a>
</sec:authorize>

  

前台由于项目比较小,没有用到js的MVC框架,如backbone等,这里就不再记录了。

posted @ 2014-04-04 08:23 paulwong 阅读(558) | 评论 (0)编辑 收藏

LOGBACK TUTORIA

https://github.com/abdulwaheed18/Slf4jTutorial 

http://stackoverflow.com/questions/10465301/tomcat-war-configure-logback-to-use-app-name-in-path

<configuration>

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
            </Pattern>
        </encoder>
    </appender>


    <appender name="FILE"
        class
="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>testFile7.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!-- daily rollover
            Once any of the below condition met, it will change the file name as below and compressed it. 
-->

            <fileNamePattern>logFile.%d{yyyy-MM-dd}.%i.log.zip
            </fileNamePattern>

            <!-- keep 30 days' worth of history -->
            <maxHistory>30</maxHistory>
            <!-- or whenever the file size reaches 10MB -->
            <timeBasedFileNamingAndTriggeringPolicy
                
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <maxFileSize>10MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
        </rollingPolicy>

        <encoder>
            <pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n
            </pattern>
        </encoder>
    </appender>

    <root level="INFO">
        <appender-ref ref="STDOUT" />
        <appender-ref ref="FILE" />
    </root>
</configuration>

posted @ 2014-04-03 08:10 paulwong 阅读(529) | 评论 (0)编辑 收藏

如何在WEB应用中绑定微信公众帐号

http://www.chanzhi.org/book/weixin.html

http://demo.chanzhi.org/chanzhiadmin.php?m=wechat&f=admin

posted @ 2014-04-01 08:41 paulwong 阅读(691) | 评论 (0)编辑 收藏

SPRING中多开发+测试多环境中的资源文件配置

property文件有几份,如
mongo_dev.properties
#intranet
mongo.replicationset=10.120.141.229:27017,10.120.141.226:27017,10.120.141.228:27017
mongo.username=cms
mongo.password=cms

mongo.dbname=cms
mongo.connectionsPerHost=100
mongo.threadsAllowedToBlockForConnectionMultiplier=4
mongo.maxWaitTime=1500
mongo.socketTimeout=1500
mongo.connectTimeout=1000
mongo.autoConnectRetry=true
mongo.socketKeepAlive=true
mongo.slaveOk=true

mongo.debug=true
mongo.trace=true


mongo_test.properties
#internet
mongo.replicationset=10.120.11.221:27017,10.120.11.122:27017,10.120.11.212:27017
mongo.username=cms
mongo.password=cms

mongo.dbname=cms
mongo.connectionsPerHost=100
mongo.threadsAllowedToBlockForConnectionMultiplier=4
mongo.maxWaitTime=1500
mongo.socketTimeout=1500
mongo.connectTimeout=1000
mongo.autoConnectRetry=true
mongo.socketKeepAlive=true
mongo.slaveOk=true

mongo.debug=false
mongo.trace=false

Spring的配置文件中加入
<context:property-placeholder
        
location="classpath*:/properties/mongodb/mongo_${spring.profiles.active}.properties />



#将下面参数放在JVM中,如果是TOMCAT则放在catalina.sh
#开发:
JAVA_OPTS="$JAVA_OPTS -Dspring.profiles.active=dev "

#测试:
JAVA_OPTS="$JAVA_OPTS -Dspring.profiles.active=test "

#如果是ECLIPSE中启动TOMCAT,则只需加
-Dspring.profiles.active=dev





posted @ 2014-03-28 10:57 paulwong 阅读(4545) | 评论 (0)编辑 收藏

MYSQL HA资源

http://stackoverflow.com/questions/22495722/mysql-master-slave-replication-connect-to-master-even-for-read-queries-does-d

http://www.dragishak.com/?p=307

http://blog.csdn.net/lixiucheng005/article/details/17391857

http://blog.csdn.net/cutesource/article/details/5710645



posted @ 2014-03-23 22:51 paulwong 阅读(305) | 评论 (0)编辑 收藏

Packt Publishing celebrates their 2000th title with an exclusive offer - We've got IT covered!

Packt Publishing celebrates their 2000th title with an exclusive offer - We've got IT covered!


 


Known for their extensive range of pragmatic IT ebooks, Packt Publishing are celebrating their 2000th book title `Learning Dart’– they want their customers to celebrate too.

To mark this milestone Packt Publishing will launch a ‘Buy One Get One Free’ offer across all eBooks on March 18th – for a limited period only.

Packt is one of the most prolific and fast-growing tech book publishers in the world. Originally focused on open source software, Packt contributes back into the community paying a royalty on relevant books directly to open source projects. These projects have received over $400,000 as part of Packt’s Open Source Royalty Scheme to date.

Their books focus on practicality, recognising that readers are ultimately concerned with getting the job done. Packt’s digitally-focused business model allows them to quickly publish up-to-date books in very specific areas across a range of key categories – web development, game development, big data, application development, and more. Their commitment to providing a comprehensive range of titles has seen Packt publish 1054% more titles in 2013 than in 2006.

Here are some of the best titles across Packt's main categories - but Buy One, Get One Free will apply across all 2000 titles:

·       Web Development

·       Big Data & Cloud

·       Game Development

·       App Development

posted @ 2014-03-23 21:53 paulwong 阅读(204) | 评论 (0)编辑 收藏

仅列出标题
共116页: First 上一页 56 57 58 59 60 61 62 63 64 下一页 Last