public boolean SendDXJL(String called, String content) {
String baseurl = configInit.baseUrl();
NameValuePair pra1=new NameValuePair("called",called);
NameValuePair pra2=new NameValuePair("content",content);
NameValuePair[] data ={pra1,pra2};
System.out.println("****************"+baseurl);
// operationState = "成功";
HttpClient client = new HttpClient();
PostMethod method = new UTF8PostMethod(baseurl);
method.setRequestBody(data);
//使用POST方法
try {
client.executeMethod(method);
//取得返回信息
method.getStatusLine();
byte[] responseBody = null;
InputStream in = method.getResponseBodyAsStream();
if (in != null) {
byte[] tmp = new byte[4096];
int bytesRead = 0;
ByteArrayOutputStream buffer = new ByteArrayOutputStream(1024);
while ((bytesRead = in.read(tmp)) != -1) {
buffer.write(tmp, 0, bytesRead);
}
responseBody = buffer.toByteArray();
}
String response = new String(responseBody, "GBK");
System.out.println(response);
//发送成功
if (response.indexOf("成功")!= -1) {
return true;
}else{
return false;
}
} catch (Exception e) {
e.printStackTrace();
}
//释放连接
method.releaseConnection();
return false;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
SmsService s=new SmsService();
s.executeSms();
}
//重写PostMethod
public static class UTF8PostMethod extends PostMethod{
public UTF8PostMethod(String url){
super(url);
}
@Override
public String getRequestCharSet() {
//return super.getRequestCharSet();
return "gb2312";
}
}
String baseurl = configInit.baseUrl();
NameValuePair pra1=new NameValuePair("called",called);
NameValuePair pra2=new NameValuePair("content",content);
NameValuePair[] data ={pra1,pra2};
System.out.println("****************"+baseurl);
// operationState = "成功";
HttpClient client = new HttpClient();
PostMethod method = new UTF8PostMethod(baseurl);
method.setRequestBody(data);
//使用POST方法
try {
client.executeMethod(method);
//取得返回信息
method.getStatusLine();
byte[] responseBody = null;
InputStream in = method.getResponseBodyAsStream();
if (in != null) {
byte[] tmp = new byte[4096];
int bytesRead = 0;
ByteArrayOutputStream buffer = new ByteArrayOutputStream(1024);
while ((bytesRead = in.read(tmp)) != -1) {
buffer.write(tmp, 0, bytesRead);
}
responseBody = buffer.toByteArray();
}
String response = new String(responseBody, "GBK");
System.out.println(response);
//发送成功
if (response.indexOf("成功")!= -1) {
return true;
}else{
return false;
}
} catch (Exception e) {
e.printStackTrace();
}
//释放连接
method.releaseConnection();
return false;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
SmsService s=new SmsService();
s.executeSms();
}
//重写PostMethod
public static class UTF8PostMethod extends PostMethod{
public UTF8PostMethod(String url){
super(url);
}
@Override
public String getRequestCharSet() {
//return super.getRequestCharSet();
return "gb2312";
}
}
解决方案 »
- java如何合并音频文件(同时间段重叠)
- spring 的事件配置
- 求weblogic-ejb-jar.xml文件的样例!
- 为什么客户调用不了Xfire Service服务端呢,,帮帮我~~~~~~
- 最近开发EJB3消息驱动BEAN时遇到了一个这样的问题 Exception in thread "main" javax.naming.CommunicationException 网上似乎没有看到这样的问题 就在某个地方看到一哈 但给出的解决方法??
- 一个hibernate4启动错误
- tomcat最难的问题:怎样增加一个新的端口????
- J2EE不能启动服务器。大哥帮帮忙啊!
- xml汉字导致解析效率超低
- 一个关于在STRUTS中打开WORD文档的问题?
- AnnotationSessionFactoryBean的问题
- 关于内部类的一点小问题,请指点!!!!
String para = "Title=中国"+"&Data=人民";