- 浏览: 97997 次
文章分类
- 全部博客 (124)
- Jquery、ajax、JavaScript (17)
- JAVA (9)
- DB (6)
- C# (1)
- Unity 3D (2)
- HTML (8)
- ognl/jstl标签 (3)
- Eclipse 开发工具 (4)
- 异常记录 (2)
- WIN7 X64 解决无法安装IE11,以及无法点击微软升级包MSU的问题 (1)
- JAVA,操作日志 (1)
- html5shiv.js和respond.min.js (1)
- dropzone的使用方法 (1)
- bootstrap (2)
- google浏览器输入框黄色 改成透明背景图片 (1)
- json (2)
- dataTables分页页码缓存问题 (1)
- 项目总结 (1)
- 前端工具--codepen (1)
- sublime text 3 (2)
- echart (1)
- H5 Canvas (1)
- CSS (15)
- 心 (1)
- 图表插件 (1)
- 地图 (1)
- 设计 (1)
- 地图-google (1)
- js---slect (1)
- 翻书插件 (1)
- document.frames不兼容火狐的问题 (1)
- js/jquery中刷新iframe方法(兼容主流) (1)
- 图标字体 (1)
- 开发工具-Chrome DevTools (1)
- webApp (0)
- 云服务 (1)
- 水平垂直居中 (2)
- 自适应 (4)
- vue (1)
- 博客论坛 (1)
- app打包 (1)
- 摄像头调用 (1)
- 摄影~~~~~~~~ (1)
- 微信--小程序 (1)
- table (1)
- 浏览器 (1)
- 前端开发工具 (1)
- 书籍收集 (1)
最新评论
package com.nos.java.action;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.httpclient.params.HttpMethodParams;
public class 参考HttpSmsUtil {
public static void main(String[] args) {
// System.out.println(new MD5().getMD5ofStr("kouyan12345").toLowerCase());
// testGetClient();
// senSmsTest();
/* testPool(); */
/* for(int i=0; i<5000; i++) {
new Thread(new Test()).start();
}*/
/* testYsy();
LoggerUtil.debug("****************************", "*******************************************");*/
// System.out.println(MD5Util.md5Hex("123456"));
// HttpSmsUtil.senSmsTest();
// HttpSmsUtil.testGetInvitedMeets();
// HttpSmsUtil.testHandShake();
// HttpSmsUtil.testYsyHandShake();
// HttpSmsUtil.testGetMobileKey();
// HttpSmsUtil.testRegCompMem();
// HttpSmsUtil.testfe();
}
public static void testPool() {
try {
HttpClient client = new HttpClient();//定义client对象
client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");//指定传送字符集为GBK格式
client.getHttpConnectionManager().getParams().setConnectionTimeout(3000);//设置连接超时时间为2秒(连接初始化时间)
PostMethod method = new PostMethod("http://10.0.7.20/linkjm.action?cid=86243850&codeid=bcqpy");
// http://192.168.10.14:8080/wms/backPlant/mobileLogin/mGetgoodsList.action
int statusCode = client.executeMethod(method);
if (statusCode != HttpStatus.SC_OK) {
System.out.println("远程访问失败。");
}
System.out.println(method.getResponseBodyAsString());//输出反馈结果
}catch(Exception e) {
e.printStackTrace();
}
}
// public static void senSmsTest() {
// try {
// HttpClient client = new HttpClient();//定义client对象
// client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");//指定传送字符集为GBK格式
// client.getHttpConnectionManager().getParams().setConnectionTimeout(2000);//设置连接超时时间为2秒(连接初始化时间)
// PostMethod method = new PostMethod("http://119.145.9.12/sendSMS.action");
// method.setRequestBody(new NameValuePair[] {
// new NameValuePair("enterpriseID" , "15591"),
// new NameValuePair("loginName" , "admin"),
// new NameValuePair("password" , MD5Util.md5Hex("kouyan12345").toLowerCase()),
// new NameValuePair("smsId" , ""),
// new NameValuePair("subPort" , "01"),
// new NameValuePair("content" , "hello sms!!"),
// new NameValuePair("mobiles" , "13725571493"),
// new NameValuePair("sendTime" , "")
// });
// int statusCode = client.executeMethod(method);
// if (statusCode != HttpStatus.SC_OK) {
// System.out.println("远程访问失败。");
// }
// System.out.println(method.getResponseBodyAsString());//输出反馈结果
// client.getHttpConnectionManager().closeIdleConnections(1);
// }catch(Exception e) {
// e.printStackTrace();
// }
// }
//
// public static void testGetClient() {
// try {
// HttpClient client = new HttpClient();//定义client对象
// client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");//指定传送字符集为GBK格式
// client.getHttpConnectionManager().getParams().setConnectionTimeout(2000);//设置连接超时时间为2秒(连接初始化时间)
// PostMethod method = new PostMethod("http://10.0.7.20/servlet/getClientAccKey");
// String sb = "CRMT:LU1FRVRVUkw9MTAuMC43LjIwL3NlcnZsZXQvZ2V0Q2xpZW50QWNjS2V5Ci1NRUVUPTg2MjQzODUwOzgwMjA0YTA2MmMyYmFhOTM1MDYxNDY5ZWNiZDIyYjQxO0NMT1VEUk9PTQotQUNOVD0wOzQ7MDg4OGQ2MWI1MTRjMzFjZTI4ZDRhZjg2NWRmNzg5MzU7NjE2YzcwNjg2MTsKLUxBTkc9emhfQ04KLU1FRVRUWVBFPU1BSU4KLUxPR0NGRz0wCi1XRUJTVlI9MTAuMC43LjIwOzEwLjAuNy4yMDsxMC4wLjcuMjA=";
// /* InputStream body = new ByteArrayInputStream(sb.getBytes());
// method.setRequestBody(body);*/
// StringRequestEntity entity = new StringRequestEntity(sb,null,"UTF-8");
// method.setRequestEntity(entity);
// int statusCode = client.executeMethod(method);
// if (statusCode != HttpStatus.SC_OK) {
// System.out.println("远程访问失败。");
// }
// // System.out.println(method.getResponseBodyAsString());//输出反馈结果
// }catch(Exception e) {
// e.printStackTrace();
// }
// }
// //http://10.0.7.20/link_start.action?codeid=bcqmq&cid=27092130&retry=0&nickname=agent1
// public static void testJoinLink() {
// try {
// HttpClient client = new HttpClient();//定义client对象
// client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");//指定传送字符集为GBK格式
// client.getHttpConnectionManager().getParams().setConnectionTimeout(2000);//设置连接超时时间为2秒(连接初始化时间)
// PostMethod method = new PostMethod("http://10.0.7.20/link_start.action?codeid=bcqpy&cid=86243850&retry=0&nickname=alpha");
// // String sb = "CRMT:LU1FRVRVUkw9MTAuMC43LjIwL3NlcnZsZXQvZ2V0Q2xpZW50QWNjS2V5Ci1NRUVUPTQwNDMxMjE5OzlkODE3ZGIxMGRjN2EyNTJlODhhMzk5OTFmOThlNmZmO0NMT1VEUk9PTQotQUNOVD0xMDAwMDAwMDM2OzE7NzU5YTRiZjAwYWRmZDA1NjQ5YjdlNjBjMTIyNjFlY2E7NjE2YzcwNjg2MTsKLUxBTkc9emhfQ04KLU1FRVRUWVBFPU1BSU4KLUxPR0NGRz0wCi1XRUJTVlI9MTAuMC43LjIwOzEwLjAuNy4yMDsxMC4xMS4xMi4xMzsxMC4wLjcuMjA=";
// /* InputStream body = new ByteArrayInputStream(sb.getBytes());
// method.setRequestBody(body);*/
// // StringRequestEntity entity = new StringRequestEntity(sb,null,"UTF-8");
// // method.setRequestEntity(entity);
// int statusCode = client.executeMethod(method);
// if (statusCode != HttpStatus.SC_OK) {
// System.out.println("远程访问失败。");
// }
// System.out.println(method.getResponseBodyAsString());//输出反馈结果
// }catch(Exception e) {
// e.printStackTrace();
// }
// }
//
// public static void testYsy() {
//
// try {
// HttpClient client = new HttpClient();//定义client对象
// client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");//指定传送字符集为GBK格式
// client.getHttpConnectionManager().getParams().setConnectionTimeout(2000);//设置连接超时时间为2秒(连接初始化时间)
// PostMethod method = new PostMethod("http://127.0.0.1/si/auth/notice?streamingno=13221345&rand=2525&encode=3231");
// int statusCode = client.executeMethod(method);
// if (statusCode != HttpStatus.SC_OK) {
// System.out.println("远程访问失败。");
// }
// System.out.println(method.getResponseBodyAsString());//输出反馈结果
// }catch(Exception e) {
// e.printStackTrace();
// }
// }
//
// public static void testImgSrc() {
//
// try {
// HttpClient client = new HttpClient();//定义client对象
// client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");//指定传送字符集为GBK格式
// client.getHttpConnectionManager().getParams().setConnectionTimeout(2000);//设置连接超时时间为2秒(连接初始化时间)
// PostMethod method = new PostMethod("http://localhost/news/81.html");
// int statusCode = client.executeMethod(method);
// if (statusCode != HttpStatus.SC_OK) {
// System.out.println("远程访问失败。");
// }
// System.out.println(method.getResponseBodyAsString());//输出反馈结果
//
// List<String> rest = getImgStr(method.getResponseBodyAsString());
// for(String rs : rest) {
// System.out.println("rs:"+rs);
// }
//
// }catch(Exception e) {
// e.printStackTrace();
// }
// }
//
// public static List<String> getImgStr(String htmlStr){
// String img="";
// Pattern p_image;
// Matcher m_image;
// List<String> pics = new ArrayList<String>();
//
// // String regEx_img = "<img.*src=(.*?)[^>]*?>"; //图片链接地址
//
// String regEx_img = "<img.*src\\s*=\\s*(.*?)[^>]*?>";
// p_image = Pattern.compile
// (regEx_img,Pattern.CASE_INSENSITIVE);
// m_image = p_image.matcher(htmlStr);
// while(m_image.find()){
// img = img + "," + m_image.group();
// // Matcher m = Pattern.compile("src=\"?(.*?)(\"|>|\\s+)").matcher(img); //匹配src
//
// Matcher m = Pattern.compile("src\\s*=\\s*\"?(.*?)(\"|>|\\s+)").matcher(img);
//
// while(m.find()){
// pics.add(m.group(1));
// }
// }
// return pics;
// }
//
//
// public static void testGetInvitedMeets() {
// try {
// HttpClient client = new HttpClient();//定义client对象
// client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");//指定传送字符集为GBK格式
// client.getHttpConnectionManager().getParams().setConnectionTimeout(2000);//设置连接超时时间为2秒(连接初始化时间)
// PostMethod method = new PostMethod("http://10.0.0.136/servlet/GetInvitedMeets");
// /* method.setRequestBody(new NameValuePair[] {
// new NameValuePair("{RequestId" , "15591ss"),
// new NameValuePair("OEMKey" , "CLOUDROOM"),
// new NameValuePair("UserPswd" , new MD5().getMD5ofStr("123456").toLowerCase()),
// new NameValuePair("ClientVer" , "1.2.0"),
// new NameValuePair("UserName" , "alpha@alpha.com}")
// }); */
// String sb = "{\"RequestId\":\"15591ss\",\"OEMKey\":\"CLOUDROOM\",\"UserPswd\":\""+MD5Util.md5Hex("123456").toLowerCase()+"\",\"ClientVer\":\"1.2.0\",\"UserName\":\"3261750121\"}";
// /* InputStream body = new ByteArrayInputStream(sb.getBytes());
// method.setRequestBody(body);*/
// StringRequestEntity entity = new StringRequestEntity(sb,null,"UTF-8");
// method.setRequestEntity(entity);
// int statusCode = client.executeMethod(method);
// if (statusCode != HttpStatus.SC_OK) {
// System.out.println("远程访问失败。");
// }
// System.out.println(method.getResponseBodyAsString());//输出反馈结果
// }catch(Exception e) {
// e.printStackTrace();
// }
// }
//
// public static void testHandShake() {
// try {
// HttpClient client = new HttpClient();//定义client对象
// client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");//指定传送字符集为GBK格式
// client.getHttpConnectionManager().getParams().setConnectionTimeout(2000);//设置连接超时时间为2秒(连接初始化时间)
// PostMethod method = new PostMethod("http://10.0.7.20/servlet/HandShake");
// /* method.setRequestBody(new NameValuePair[] {
// new NameValuePair("{RequestId" , "15591ss"),
// new NameValuePair("OEMKey" , "CLOUDROOM"),
// new NameValuePair("UserPswd" , new MD5().getMD5ofStr("123456").toLowerCase()),
// new NameValuePair("ClientVer" , "1.2.0"),
// new NameValuePair("UserName" , "alpha@alpha.com}")
// }); */
// String sb = "{\"RequestId\":\"15591ss\",\"OEMKey\":\"CLOUDROOM\",\"UserPswd\":\""+MD5Util.md5Hex("123456").toLowerCase()+"\",\"ClientVer\":\"1.2.0\",\"UserName\":\"3261750121\",\"MeetID\":\"12345678\",\"Status\":\"2\"}";
// /* InputStream body = new ByteArrayInputStream(sb.getBytes());
// method.setRequestBody(body);*/
// StringRequestEntity entity = new StringRequestEntity(sb,null,"UTF-8");
// method.setRequestEntity(entity);
// int statusCode = client.executeMethod(method);
// if (statusCode != HttpStatus.SC_OK) {
// System.out.println("远程访问失败。");
// }
// System.out.println(method.getResponseBodyAsString());//输出反馈结果
// }catch(Exception e) {
// e.printStackTrace();
// }
// }
//
//
// public static void testYsyHandShake() {
// try {
// HttpClient client = new HttpClient();//定义client对象
// client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");//指定传送字符集为GBK格式
// client.getHttpConnectionManager().getParams().setConnectionTimeout(5000);//设置连接超时时间为2秒(连接初始化时间)
// PostMethod method = new PostMethod("http://www.189esy.cn:8080/FS-ECD-CLIENT/loginForPhone");
// /* method.setRequestBody(new NameValuePair[] {
// new NameValuePair("{RequestId" , "15591ss"),
// new NameValuePair("OEMKey" , "CLOUDROOM"),
// new NameValuePair("UserPswd" , new MD5().getMD5ofStr("123456").toLowerCase()),
// new NameValuePair("ClientVer" , "1.2.0"),
// new NameValuePair("UserName" , "alpha@alpha.com}")
// }); */
// long epoch = System.currentTimeMillis()/1000;
// String sb = "{\"userid\":\"18906917784\",\"password\":\"654321a\",\"encrypted\":\"0\",\"imei\":\"359652053048984\",\"appid\":\"140002350000000000000011\",\"timestamp\":\""+epoch+"\",\"authenticator\":\""+MD5Util.ysymd5("18906917784"+"654321a"+"359652053048984"+"140002350000000000000011"+epoch+"5029C3055D51")+"\"}";
// // String sb = "{userid:'master@1163688247',password:'n3P//IKYRk1Q7TzGDZqp3g==',encrypted:'1',imei:'359652053048984',appid:'140002350000000000000011',timestamp:'1414999077',authenticator:'LHlgdJhqKiyrVrhJA/RLxA=='}";
// /* InputStream body = new ByteArrayInputStream(sb.getBytes());
// method.setRequestBody(body);*/
// StringRequestEntity entity = new StringRequestEntity(sb,"application/json","UTF-8");
// method.setRequestEntity(entity);
// int statusCode = client.executeMethod(method);
// if (statusCode != HttpStatus.SC_OK) {
// System.out.println("远程访问失败。");
// }
// System.out.println(method.getResponseBodyAsString());//输出反馈结果
// }catch(Exception e) {
// e.printStackTrace();
// }
// }
//
// public static void testGetMobileKey() {
// try {
// HttpClient client = new HttpClient();//定义client对象
// client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");//指定传送字符集为GBK格式
// client.getHttpConnectionManager().getParams().setConnectionTimeout(2000);//设置连接超时时间为2秒(连接初始化时间)
// PostMethod method = new PostMethod("http://127.0.0.1/appws/app/register/getSmsKey");
//
// String sb = "{\"RequestId\":\"15591ss\",\"mobile\":\"13725571493\"}";
// StringRequestEntity entity = new StringRequestEntity(sb,"application/json","UTF-8");
//
// method.setRequestEntity(entity);
//
// int statusCode = client.executeMethod(method);
// if (statusCode != HttpStatus.SC_OK) {
// System.out.println("远程访问失败。");
// }
// System.out.println(method.getResponseBodyAsString());//输出反馈结果
// }catch(Exception e) {
// e.printStackTrace();
// }
// }
//
// public static void testRegCompMem() {
// try {
// HttpClient client = new HttpClient();//定义client对象
// client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");//指定传送字符集为GBK格式
// client.getHttpConnectionManager().getParams().setConnectionTimeout(5000);//设置连接超时时间为2秒(连接初始化时间)
// PostMethod method = new PostMethod("http://127.0.0.1/appws/app/register/regmem");
// String sb = "{\"RequestId\":\"cccccccccc13213\",\"mobile\":\"13725571493\",\"compMobile\":\"17790090601\",\"identifyCode\":\"960925\"}";
// StringRequestEntity entity = new StringRequestEntity(sb,"application/json","UTF-8");
// method.setRequestEntity(entity);
// int statusCode = client.executeMethod(method);
// if (statusCode != HttpStatus.SC_OK) {
// System.out.println("远程访问失败。");
// }
// System.out.println(method.getResponseBodyAsString());//输出反馈结果
// }catch(Exception e) {
// e.printStackTrace();
// }
// }
//
// public static void testfe() {
// try {
// HttpClient client = new HttpClient();//定义client对象
// client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");//指定传送字符集为GBK格式
// client.getHttpConnectionManager().getParams().setConnectionTimeout(5000);//设置连接超时时间为2秒(连接初始化时间)
// PostMethod method = new PostMethod("http://10.2.11.123/appws/app/cmpuser/adduser");
// String sb = "{\"RequestId\":\"cccccccccc13213\",\"mobile\":\"13725571493\",\"compMobile\":\"17790090601\",\"identifyCode\":\"960925\"}";
// StringRequestEntity entity = new StringRequestEntity(sb,"application/json","UTF-8");
// method.setRequestEntity(entity);
// int statusCode = client.executeMethod(method);
// if (statusCode != HttpStatus.SC_OK) {
// System.out.println("远程访问失败。");
// }
// System.out.println(method.getResponseBodyAsString());//输出反馈结果
// }catch(Exception e) {
// e.printStackTrace();
// }
// }
//
//}
class Test implements Runnable{
public void run() {
参考HttpSmsUtil.testPool();
// HttpSmsUtil.testGetClient();
// HttpSmsUtil.testJoinLink();
}
}
}
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.httpclient.params.HttpMethodParams;
public class 参考HttpSmsUtil {
public static void main(String[] args) {
// System.out.println(new MD5().getMD5ofStr("kouyan12345").toLowerCase());
// testGetClient();
// senSmsTest();
/* testPool(); */
/* for(int i=0; i<5000; i++) {
new Thread(new Test()).start();
}*/
/* testYsy();
LoggerUtil.debug("****************************", "*******************************************");*/
// System.out.println(MD5Util.md5Hex("123456"));
// HttpSmsUtil.senSmsTest();
// HttpSmsUtil.testGetInvitedMeets();
// HttpSmsUtil.testHandShake();
// HttpSmsUtil.testYsyHandShake();
// HttpSmsUtil.testGetMobileKey();
// HttpSmsUtil.testRegCompMem();
// HttpSmsUtil.testfe();
}
public static void testPool() {
try {
HttpClient client = new HttpClient();//定义client对象
client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");//指定传送字符集为GBK格式
client.getHttpConnectionManager().getParams().setConnectionTimeout(3000);//设置连接超时时间为2秒(连接初始化时间)
PostMethod method = new PostMethod("http://10.0.7.20/linkjm.action?cid=86243850&codeid=bcqpy");
// http://192.168.10.14:8080/wms/backPlant/mobileLogin/mGetgoodsList.action
int statusCode = client.executeMethod(method);
if (statusCode != HttpStatus.SC_OK) {
System.out.println("远程访问失败。");
}
System.out.println(method.getResponseBodyAsString());//输出反馈结果
}catch(Exception e) {
e.printStackTrace();
}
}
// public static void senSmsTest() {
// try {
// HttpClient client = new HttpClient();//定义client对象
// client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");//指定传送字符集为GBK格式
// client.getHttpConnectionManager().getParams().setConnectionTimeout(2000);//设置连接超时时间为2秒(连接初始化时间)
// PostMethod method = new PostMethod("http://119.145.9.12/sendSMS.action");
// method.setRequestBody(new NameValuePair[] {
// new NameValuePair("enterpriseID" , "15591"),
// new NameValuePair("loginName" , "admin"),
// new NameValuePair("password" , MD5Util.md5Hex("kouyan12345").toLowerCase()),
// new NameValuePair("smsId" , ""),
// new NameValuePair("subPort" , "01"),
// new NameValuePair("content" , "hello sms!!"),
// new NameValuePair("mobiles" , "13725571493"),
// new NameValuePair("sendTime" , "")
// });
// int statusCode = client.executeMethod(method);
// if (statusCode != HttpStatus.SC_OK) {
// System.out.println("远程访问失败。");
// }
// System.out.println(method.getResponseBodyAsString());//输出反馈结果
// client.getHttpConnectionManager().closeIdleConnections(1);
// }catch(Exception e) {
// e.printStackTrace();
// }
// }
//
// public static void testGetClient() {
// try {
// HttpClient client = new HttpClient();//定义client对象
// client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");//指定传送字符集为GBK格式
// client.getHttpConnectionManager().getParams().setConnectionTimeout(2000);//设置连接超时时间为2秒(连接初始化时间)
// PostMethod method = new PostMethod("http://10.0.7.20/servlet/getClientAccKey");
// String sb = "CRMT:LU1FRVRVUkw9MTAuMC43LjIwL3NlcnZsZXQvZ2V0Q2xpZW50QWNjS2V5Ci1NRUVUPTg2MjQzODUwOzgwMjA0YTA2MmMyYmFhOTM1MDYxNDY5ZWNiZDIyYjQxO0NMT1VEUk9PTQotQUNOVD0wOzQ7MDg4OGQ2MWI1MTRjMzFjZTI4ZDRhZjg2NWRmNzg5MzU7NjE2YzcwNjg2MTsKLUxBTkc9emhfQ04KLU1FRVRUWVBFPU1BSU4KLUxPR0NGRz0wCi1XRUJTVlI9MTAuMC43LjIwOzEwLjAuNy4yMDsxMC4wLjcuMjA=";
// /* InputStream body = new ByteArrayInputStream(sb.getBytes());
// method.setRequestBody(body);*/
// StringRequestEntity entity = new StringRequestEntity(sb,null,"UTF-8");
// method.setRequestEntity(entity);
// int statusCode = client.executeMethod(method);
// if (statusCode != HttpStatus.SC_OK) {
// System.out.println("远程访问失败。");
// }
// // System.out.println(method.getResponseBodyAsString());//输出反馈结果
// }catch(Exception e) {
// e.printStackTrace();
// }
// }
// //http://10.0.7.20/link_start.action?codeid=bcqmq&cid=27092130&retry=0&nickname=agent1
// public static void testJoinLink() {
// try {
// HttpClient client = new HttpClient();//定义client对象
// client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");//指定传送字符集为GBK格式
// client.getHttpConnectionManager().getParams().setConnectionTimeout(2000);//设置连接超时时间为2秒(连接初始化时间)
// PostMethod method = new PostMethod("http://10.0.7.20/link_start.action?codeid=bcqpy&cid=86243850&retry=0&nickname=alpha");
// // String sb = "CRMT:LU1FRVRVUkw9MTAuMC43LjIwL3NlcnZsZXQvZ2V0Q2xpZW50QWNjS2V5Ci1NRUVUPTQwNDMxMjE5OzlkODE3ZGIxMGRjN2EyNTJlODhhMzk5OTFmOThlNmZmO0NMT1VEUk9PTQotQUNOVD0xMDAwMDAwMDM2OzE7NzU5YTRiZjAwYWRmZDA1NjQ5YjdlNjBjMTIyNjFlY2E7NjE2YzcwNjg2MTsKLUxBTkc9emhfQ04KLU1FRVRUWVBFPU1BSU4KLUxPR0NGRz0wCi1XRUJTVlI9MTAuMC43LjIwOzEwLjAuNy4yMDsxMC4xMS4xMi4xMzsxMC4wLjcuMjA=";
// /* InputStream body = new ByteArrayInputStream(sb.getBytes());
// method.setRequestBody(body);*/
// // StringRequestEntity entity = new StringRequestEntity(sb,null,"UTF-8");
// // method.setRequestEntity(entity);
// int statusCode = client.executeMethod(method);
// if (statusCode != HttpStatus.SC_OK) {
// System.out.println("远程访问失败。");
// }
// System.out.println(method.getResponseBodyAsString());//输出反馈结果
// }catch(Exception e) {
// e.printStackTrace();
// }
// }
//
// public static void testYsy() {
//
// try {
// HttpClient client = new HttpClient();//定义client对象
// client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");//指定传送字符集为GBK格式
// client.getHttpConnectionManager().getParams().setConnectionTimeout(2000);//设置连接超时时间为2秒(连接初始化时间)
// PostMethod method = new PostMethod("http://127.0.0.1/si/auth/notice?streamingno=13221345&rand=2525&encode=3231");
// int statusCode = client.executeMethod(method);
// if (statusCode != HttpStatus.SC_OK) {
// System.out.println("远程访问失败。");
// }
// System.out.println(method.getResponseBodyAsString());//输出反馈结果
// }catch(Exception e) {
// e.printStackTrace();
// }
// }
//
// public static void testImgSrc() {
//
// try {
// HttpClient client = new HttpClient();//定义client对象
// client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");//指定传送字符集为GBK格式
// client.getHttpConnectionManager().getParams().setConnectionTimeout(2000);//设置连接超时时间为2秒(连接初始化时间)
// PostMethod method = new PostMethod("http://localhost/news/81.html");
// int statusCode = client.executeMethod(method);
// if (statusCode != HttpStatus.SC_OK) {
// System.out.println("远程访问失败。");
// }
// System.out.println(method.getResponseBodyAsString());//输出反馈结果
//
// List<String> rest = getImgStr(method.getResponseBodyAsString());
// for(String rs : rest) {
// System.out.println("rs:"+rs);
// }
//
// }catch(Exception e) {
// e.printStackTrace();
// }
// }
//
// public static List<String> getImgStr(String htmlStr){
// String img="";
// Pattern p_image;
// Matcher m_image;
// List<String> pics = new ArrayList<String>();
//
// // String regEx_img = "<img.*src=(.*?)[^>]*?>"; //图片链接地址
//
// String regEx_img = "<img.*src\\s*=\\s*(.*?)[^>]*?>";
// p_image = Pattern.compile
// (regEx_img,Pattern.CASE_INSENSITIVE);
// m_image = p_image.matcher(htmlStr);
// while(m_image.find()){
// img = img + "," + m_image.group();
// // Matcher m = Pattern.compile("src=\"?(.*?)(\"|>|\\s+)").matcher(img); //匹配src
//
// Matcher m = Pattern.compile("src\\s*=\\s*\"?(.*?)(\"|>|\\s+)").matcher(img);
//
// while(m.find()){
// pics.add(m.group(1));
// }
// }
// return pics;
// }
//
//
// public static void testGetInvitedMeets() {
// try {
// HttpClient client = new HttpClient();//定义client对象
// client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");//指定传送字符集为GBK格式
// client.getHttpConnectionManager().getParams().setConnectionTimeout(2000);//设置连接超时时间为2秒(连接初始化时间)
// PostMethod method = new PostMethod("http://10.0.0.136/servlet/GetInvitedMeets");
// /* method.setRequestBody(new NameValuePair[] {
// new NameValuePair("{RequestId" , "15591ss"),
// new NameValuePair("OEMKey" , "CLOUDROOM"),
// new NameValuePair("UserPswd" , new MD5().getMD5ofStr("123456").toLowerCase()),
// new NameValuePair("ClientVer" , "1.2.0"),
// new NameValuePair("UserName" , "alpha@alpha.com}")
// }); */
// String sb = "{\"RequestId\":\"15591ss\",\"OEMKey\":\"CLOUDROOM\",\"UserPswd\":\""+MD5Util.md5Hex("123456").toLowerCase()+"\",\"ClientVer\":\"1.2.0\",\"UserName\":\"3261750121\"}";
// /* InputStream body = new ByteArrayInputStream(sb.getBytes());
// method.setRequestBody(body);*/
// StringRequestEntity entity = new StringRequestEntity(sb,null,"UTF-8");
// method.setRequestEntity(entity);
// int statusCode = client.executeMethod(method);
// if (statusCode != HttpStatus.SC_OK) {
// System.out.println("远程访问失败。");
// }
// System.out.println(method.getResponseBodyAsString());//输出反馈结果
// }catch(Exception e) {
// e.printStackTrace();
// }
// }
//
// public static void testHandShake() {
// try {
// HttpClient client = new HttpClient();//定义client对象
// client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");//指定传送字符集为GBK格式
// client.getHttpConnectionManager().getParams().setConnectionTimeout(2000);//设置连接超时时间为2秒(连接初始化时间)
// PostMethod method = new PostMethod("http://10.0.7.20/servlet/HandShake");
// /* method.setRequestBody(new NameValuePair[] {
// new NameValuePair("{RequestId" , "15591ss"),
// new NameValuePair("OEMKey" , "CLOUDROOM"),
// new NameValuePair("UserPswd" , new MD5().getMD5ofStr("123456").toLowerCase()),
// new NameValuePair("ClientVer" , "1.2.0"),
// new NameValuePair("UserName" , "alpha@alpha.com}")
// }); */
// String sb = "{\"RequestId\":\"15591ss\",\"OEMKey\":\"CLOUDROOM\",\"UserPswd\":\""+MD5Util.md5Hex("123456").toLowerCase()+"\",\"ClientVer\":\"1.2.0\",\"UserName\":\"3261750121\",\"MeetID\":\"12345678\",\"Status\":\"2\"}";
// /* InputStream body = new ByteArrayInputStream(sb.getBytes());
// method.setRequestBody(body);*/
// StringRequestEntity entity = new StringRequestEntity(sb,null,"UTF-8");
// method.setRequestEntity(entity);
// int statusCode = client.executeMethod(method);
// if (statusCode != HttpStatus.SC_OK) {
// System.out.println("远程访问失败。");
// }
// System.out.println(method.getResponseBodyAsString());//输出反馈结果
// }catch(Exception e) {
// e.printStackTrace();
// }
// }
//
//
// public static void testYsyHandShake() {
// try {
// HttpClient client = new HttpClient();//定义client对象
// client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");//指定传送字符集为GBK格式
// client.getHttpConnectionManager().getParams().setConnectionTimeout(5000);//设置连接超时时间为2秒(连接初始化时间)
// PostMethod method = new PostMethod("http://www.189esy.cn:8080/FS-ECD-CLIENT/loginForPhone");
// /* method.setRequestBody(new NameValuePair[] {
// new NameValuePair("{RequestId" , "15591ss"),
// new NameValuePair("OEMKey" , "CLOUDROOM"),
// new NameValuePair("UserPswd" , new MD5().getMD5ofStr("123456").toLowerCase()),
// new NameValuePair("ClientVer" , "1.2.0"),
// new NameValuePair("UserName" , "alpha@alpha.com}")
// }); */
// long epoch = System.currentTimeMillis()/1000;
// String sb = "{\"userid\":\"18906917784\",\"password\":\"654321a\",\"encrypted\":\"0\",\"imei\":\"359652053048984\",\"appid\":\"140002350000000000000011\",\"timestamp\":\""+epoch+"\",\"authenticator\":\""+MD5Util.ysymd5("18906917784"+"654321a"+"359652053048984"+"140002350000000000000011"+epoch+"5029C3055D51")+"\"}";
// // String sb = "{userid:'master@1163688247',password:'n3P//IKYRk1Q7TzGDZqp3g==',encrypted:'1',imei:'359652053048984',appid:'140002350000000000000011',timestamp:'1414999077',authenticator:'LHlgdJhqKiyrVrhJA/RLxA=='}";
// /* InputStream body = new ByteArrayInputStream(sb.getBytes());
// method.setRequestBody(body);*/
// StringRequestEntity entity = new StringRequestEntity(sb,"application/json","UTF-8");
// method.setRequestEntity(entity);
// int statusCode = client.executeMethod(method);
// if (statusCode != HttpStatus.SC_OK) {
// System.out.println("远程访问失败。");
// }
// System.out.println(method.getResponseBodyAsString());//输出反馈结果
// }catch(Exception e) {
// e.printStackTrace();
// }
// }
//
// public static void testGetMobileKey() {
// try {
// HttpClient client = new HttpClient();//定义client对象
// client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");//指定传送字符集为GBK格式
// client.getHttpConnectionManager().getParams().setConnectionTimeout(2000);//设置连接超时时间为2秒(连接初始化时间)
// PostMethod method = new PostMethod("http://127.0.0.1/appws/app/register/getSmsKey");
//
// String sb = "{\"RequestId\":\"15591ss\",\"mobile\":\"13725571493\"}";
// StringRequestEntity entity = new StringRequestEntity(sb,"application/json","UTF-8");
//
// method.setRequestEntity(entity);
//
// int statusCode = client.executeMethod(method);
// if (statusCode != HttpStatus.SC_OK) {
// System.out.println("远程访问失败。");
// }
// System.out.println(method.getResponseBodyAsString());//输出反馈结果
// }catch(Exception e) {
// e.printStackTrace();
// }
// }
//
// public static void testRegCompMem() {
// try {
// HttpClient client = new HttpClient();//定义client对象
// client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");//指定传送字符集为GBK格式
// client.getHttpConnectionManager().getParams().setConnectionTimeout(5000);//设置连接超时时间为2秒(连接初始化时间)
// PostMethod method = new PostMethod("http://127.0.0.1/appws/app/register/regmem");
// String sb = "{\"RequestId\":\"cccccccccc13213\",\"mobile\":\"13725571493\",\"compMobile\":\"17790090601\",\"identifyCode\":\"960925\"}";
// StringRequestEntity entity = new StringRequestEntity(sb,"application/json","UTF-8");
// method.setRequestEntity(entity);
// int statusCode = client.executeMethod(method);
// if (statusCode != HttpStatus.SC_OK) {
// System.out.println("远程访问失败。");
// }
// System.out.println(method.getResponseBodyAsString());//输出反馈结果
// }catch(Exception e) {
// e.printStackTrace();
// }
// }
//
// public static void testfe() {
// try {
// HttpClient client = new HttpClient();//定义client对象
// client.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");//指定传送字符集为GBK格式
// client.getHttpConnectionManager().getParams().setConnectionTimeout(5000);//设置连接超时时间为2秒(连接初始化时间)
// PostMethod method = new PostMethod("http://10.2.11.123/appws/app/cmpuser/adduser");
// String sb = "{\"RequestId\":\"cccccccccc13213\",\"mobile\":\"13725571493\",\"compMobile\":\"17790090601\",\"identifyCode\":\"960925\"}";
// StringRequestEntity entity = new StringRequestEntity(sb,"application/json","UTF-8");
// method.setRequestEntity(entity);
// int statusCode = client.executeMethod(method);
// if (statusCode != HttpStatus.SC_OK) {
// System.out.println("远程访问失败。");
// }
// System.out.println(method.getResponseBodyAsString());//输出反馈结果
// }catch(Exception e) {
// e.printStackTrace();
// }
// }
//
//}
class Test implements Runnable{
public void run() {
参考HttpSmsUtil.testPool();
// HttpSmsUtil.testGetClient();
// HttpSmsUtil.testJoinLink();
}
}
}
发表评论
-
HttpClient通过HttpPost传递参数,Connection reset by peer: socket write error
2017-01-09 15:51 1947原文链接:HttpClient通过HttpPost传递参数 ... -
JavaWeb 服务启动时,在后台启动加载一个线程。
2016-12-08 21:09 517原文: JavaWeb 服务启动时,在后台启动加载一个线 ... -
使用sping AOP 操作日志管理
2016-11-28 19:29 419[置顶] 使用sping AOP 操作日志管理 记录 ... -
Java2Wordjava.lang.Exception: 初始化类库出错,请检查是否使用安装程序在本机器进行了安装。 如果简单地从其它机器拷贝安装目录到本机器
2016-05-26 11:43 2040java.lang.Exception: 初始化类库出错,请 ... -
计算时间差,两种输出格式
2016-04-18 11:45 664package com.nos.lctp.basePlane ... -
expected single matching bean but found 2
2016-03-10 09:27 653今天写完两个service实现,启动项目发现了这个错 ... -
httpclient 请求 post、get
2015-07-01 11:29 490如果PostMethod提交的是中文字符,需要加上相应的编 ... -
java实现中文汉字的首字母排序
2015-05-11 10:32 580java中可以排序的工具类和接口共有五个SortedMap 、 ...
相关推荐
《深入解析httpclient.jar及其与code.jar的关联》 在Java开发中,HTTP通信是不可或缺的一部分,而Apache HttpClient库正是Java实现HTTP客户端操作的重要工具。本文将深入探讨httpclient.jar包,以及它与code.jar包...
### Httpclient官网教程中文版知识点总结 #### 一、引言 HTTP协议作为互联网的核心通信标准之一,在现代网络服务及物联网设备中扮演着至关重要的角色。随着技术的发展,越来越多的应用和服务依赖于HTTP协议来实现...
HttpClient 4.2.1版本引入了一些重要的改进和修复,以提高性能和稳定性。以下是一些关键特性: 1. **连接管理**:HttpClient 4.2.1引入了更完善的连接管理机制,允许开发者控制连接的创建、复用和关闭。`...
例如,在HttpClient 3.x中,代码可能会使用`***mons.httpclient.HttpClient`类和`***mons.httpclient.methods.GetMethod`等,而在4.x版本中,这些都被新的API所替代。程序员需要熟悉`org.apache....
赠送jar包:httpclient-4.2.5.jar; 赠送原API文档:httpclient-4.2.5-javadoc.jar; 赠送源代码:httpclient-4.2.5-sources.jar; 赠送Maven依赖信息文件:httpclient-4.2.5.pom; 包含翻译后的API文档:httpclient...
本文将深入探讨HttpClient 4.2.1的核心特性和使用方法,帮助开发者更好地理解和应用这个强大的工具。 一、HttpClient简介 HttpClient是一个开放源码的Java库,由Apache软件基金会维护。它为Java程序员提供了一个...