1. 接口及地址
所有接口访问采用resetful接口,提交和返回数据均使用json格式,接口描述文件可通过下面的接口进行访问:http://192.168.100.17/ws/restful?_wadl
2.接口/方法名称:
ws/restful/dcm/asset/getdeviceinfo
3. 接口/方法请求方式:POST
/**
*通过Http-Client 框架来模拟实现 Http请求--post
*/
public static String getMointAssetInfo(String method, String serviceTag) throws Exception {
// method= "http://192.168.100.17/ws/restful/dcm/asset/getdeviceinfo"
String result = "";
if (null != serviceTag ) {
// 输入服务网址
HttpClient client = new HttpClient();
// GetMethod
PostMethod post = new PostMethod(method);
// 设置参数
JSONObject jsonObject = new JSONObject();
// jsonObject.put("ip","");
/*序列号*/
jsonObject.put("sn",serviceTag);
/*接口访问验证token,加密字符串*/
jsonObject.put("token","B069446BB495791571DD6264BCEA0C32");
String toJson = jsonObject.toString();
RequestEntity se = new StringRequestEntity(toJson ,"application/json" ,"UTF-8");
post.setRequestEntity(se);
/*返回数据乱码*/
post.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET,"utf-8");
// 执行,返回一个结果码
int code = client.executeMethod(post);
// 获取xml结果
result=post.getResponseBodyAsString();
//释放连接
post.releaseConnection();
}
return result;
}