- 浏览: 97843 次
文章分类
- 全部博客 (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 1946原文链接:HttpClient通过HttpPost传递参数 ... -
JavaWeb 服务启动时,在后台启动加载一个线程。
2016-12-08 21:09 516原文: JavaWeb 服务启动时,在后台启动加载一个线 ... -
使用sping AOP 操作日志管理
2016-11-28 19:29 418[置顶] 使用sping AOP 操作日志管理 记录 ... -
Java2Wordjava.lang.Exception: 初始化类库出错,请检查是否使用安装程序在本机器进行了安装。 如果简单地从其它机器拷贝安装目录到本机器
2016-05-26 11:43 2036java.lang.Exception: 初始化类库出错,请 ... -
计算时间差,两种输出格式
2016-04-18 11:45 664package com.nos.lctp.basePlane ... -
expected single matching bean but found 2
2016-03-10 09:27 651今天写完两个service实现,启动项目发现了这个错 ... -
httpclient 请求 post、get
2015-07-01 11:29 485如果PostMethod提交的是中文字符,需要加上相应的编 ... -
java实现中文汉字的首字母排序
2015-05-11 10:32 577java中可以排序的工具类和接口共有五个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程序员提供了一个...
HttpClient httpClient = new HttpClient(); // 设置 Http 连接超时为5秒 httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(5000); /* 2 生成 GetMethod 对象并设置参数 */ GetMethod ...
赠送jar包:httpclient-4.5.6.jar; 赠送原API文档:httpclient-4.5.6-javadoc.jar; 赠送源代码:httpclient-4.5.6-sources.jar; 赠送Maven依赖信息文件:httpclient-4.5.6.pom; 包含翻译后的API文档:httpclient...
本篇文章将深入探讨如何使用HttpClient方式调用URL,以及相关的知识点。 首先,HttpClient允许我们构建复杂的HTTP请求,包括GET、POST以及其他HTTP方法。使用HttpClient调用URL的基本步骤包括创建HttpClient实例、...
使用HttpClient发送请求、接收响应很简单,一般需要如下几步即可。 1. 创建HttpClient对象。 2. 创建请求方法的实例,并指定请求URL。如果需要发送GET请求,创建HttpGet对象;如果需要发送POST请求,创建...
HttpClientHelper 对这个类进行了封装,使得开发者无需直接与HttpClient接口打交道,而是通过更简洁、易用的方法调用来实现网络通信。这提高了代码的可读性和可维护性。 单例模式是软件设计模式的一种,确保一个类...
HttpClient 4.13版本是这个库的一个较新版本,包含了一系列的改进和修复。 在Java开发中,HttpClient是一个常用的工具,尤其在处理Web服务或者API调用时。它支持同步和异步操作,可以处理复杂的HTTP协议细节,使...
这个实例主要涉及如何配置HttpClient来忽略SSL(Secure Socket Layer)验证,这对于在开发和测试环境中处理自签名证书或未认证的服务器非常有用。以下将详细介绍HttpClient的使用以及如何进行SSL验证的忽略。 首先...
《HttpClient 4.5详解与应用实践》 HttpClient是一个开源的Java库,由Apache软件基金会维护,主要用于在HTTP协议上实现客户端的通信。版本4.5是HttpClient的一个稳定版本,提供了许多增强的功能和优化,使其成为...
本压缩包文件"httpClient"很可能包含了HttpClient库所需的必备JAR文件,这些文件通常包括HttpClient的核心库、依赖的第三方库以及可能的扩展模块。为了正确使用HttpClient,你需要确保将这些JAR文件添加到你的项目类...
《深入理解HTTPClient 4.5及其依赖》 在Java编程世界中,HTTPClient是一个非常重要的库,它允许开发者执行HTTP请求并处理响应。本文将深入探讨`httpclient-4.5.jar`这个包,以及它所依赖的相关jar包,帮助你更好地...
在本文中,我们将深入探讨如何使用HttpClient调用WebService。 首先,调用WebService通常涉及SOAP(Simple Object Access Protocol)或RESTful API。HttpClient可以处理这两种类型的Web服务。在本示例中,我们假设...
赠送jar包:httpclient-4.5.13.jar; 赠送原API文档:httpclient-4.5.13-javadoc.jar; 赠送源代码:httpclient-4.5.13-sources.jar; 赠送Maven依赖信息文件:httpclient-4.5.13.pom; 包含翻译后的API文档:...
赠送jar包:httpclient-4.5.5.jar; 赠送原API文档:httpclient-4.5.5-javadoc.jar; 赠送源代码:httpclient-4.5.5-sources.jar; 包含翻译后的API文档:httpclient-4.5.5-javadoc-API文档-中文(简体)版.zip ...
### HTTPClient知识点详解 #### 1. HttpClient4 – 获取状态码 **1.1 概览** 本节将详细介绍如何使用HttpClient 4.x版本来获取HTTP响应的状态码,并对其进行验证。这对于开发人员来说是一个非常实用的功能,可以...