apiindex.jsp 7.1 KB
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="../utilJS/jquery-1.8.2.min.js" type="text/javascript"></script>


<script type="text/javascript">
	$(document).ready(function(){
		$("#apireturn").hide();
		$("#apicanshu").hide();
	});
	function checkdiv(id){
		if(id==1){
			$("#apicontext").show();
			$("#apireturn").hide();
			$("#apicanshu").hide();
		}else if(id==2){
			$("#apicontext").hide();
			$("#apireturn").hide();
			$("#apicanshu").show();
		}else if(id==3){
			$("#apicontext").hide();
			$("#apireturn").show();
			$("#apicanshu").hide();
		}
		
	}
</script>
</head>
<body>
	<div>
    	<div style="float:left; width:300px; height:600px; background-color:#EEE;">
       		<li><a href="javascript:void(0);" onclick="checkdiv(1)">java调用实例</a></li> 
       		<li><a href="javascript:void(0);" onclick="checkdiv(2)">java参数说明</a></li> 
        	<li><a href="javascript:void(0);" onclick="checkdiv(3)">返回值说明</a></li> 
        </div>
    	<div style="height:600px; overflow:scroll;" >
<div id="apicontext">
<pre>
package com.httpclient;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse; 
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.apache.poi.hssf.record.FilePassRecord;

public class ClientTest {
    private static HttpClient httpclient;

    @SuppressWarnings("deprecation")
    public static void main(String[] args) {
        try {
            String url = "http://yinxiaoyou.com:8080/espeedYxyService/httpsendservice.action";  
            httpclient = new DefaultHttpClient();//定义链接				
            HttpPost httppost = new HttpPost(url);//请求处理页面 
            //上传的图片
            FileBody imgfile = new FileBody(new File("H:/中文图片.png"));
            StringBody httpimgFileName = new StringBody("中文图片.png",Charset.forName("UTF-8"));
            //上传的附件
            FileBody httpattrFile = new FileBody(new File("H:/ceshi.eml"));
            StringBody httpattrFileName=new StringBody("ceshi.eml",Charset.forName("UTF-8"));
            //定义传递的值(用户信息)
            StringBody httpdomain = new StringBody("21gmail.com",Charset.forName("UTF-8"));
            StringBody httploginid = new StringBody("info",Charset.forName("UTF-8"));
            StringBody httpaip = new StringBody("123456",Charset.forName("UTF-8"));
            
            //邮件信息
            StringBody httpto = new StringBody("435298846@qq.com",Charset.forName("UTF-8"));
            StringBody httpfrom = new StringBody("274603467@qq.com",Charset.forName("UTF-8"));
            StringBody httpfromname = new StringBody("谢勇",Charset.forName("UTF-8"));
            StringBody httpreplyto = new StringBody("435298846@qq.com",Charset.forName("UTF-8"));
            StringBody httptitle = new StringBody("http发送邮件情况!",Charset.forName("UTF-8"));
            StringBody httpismanytitle = new StringBody("0");//是否多主题
            StringBody httpbody = new StringBody("what that.......<img src='cid:IMG0'/>",Charset.forName("UTF-8"));
                    
            //对请求的表单域进行填充  
            MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE, null, Charset.forName("UTF-8"));  
            reqEntity.addPart("httpimgFile", imgfile);//图片
            reqEntity.addPart("httpimgFileName",httpimgFileName);//图片名
            
            reqEntity.addPart("httpattrFile", httpattrFile);//附件
            reqEntity.addPart("httpattrFileName",httpattrFileName);//附件名
            
            //用户信息
            reqEntity.addPart("httpdomain",httpdomain);//用户域名  
            reqEntity.addPart("httploginid", httploginid);//用户帐号
            reqEntity.addPart("httpaip", httpaip);//aip
            
            //邮件信息
            reqEntity.addPart("httpto",httpto);//收件人
            reqEntity.addPart("httpfromname", httpfromname);//发件人姓名
            reqEntity.addPart("httpfrom", httpfrom);//发件人地址
            reqEntity.addPart("httpreplyto", httpreplyto);//回复地址
            reqEntity.addPart("httptitle",httptitle);//主题	
            reqEntity.addPart("httpismanytitle",httpismanytitle);//是否多主题
            reqEntity.addPart("httpbody", httpbody);//内容
            
            
            System.out.println(reqEntity.getContentEncoding());
            
            //设置请求  
            httppost.setEntity(reqEntity);
            //执行  
            HttpResponse response = httpclient.execute(httppost);  
        
            BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));  
            String line = "";  
            while((line = rd.readLine()) != null) {  
                System.out.println(line);  
            }    
        } catch (Exception e) {
            e.printStackTrace();
        }
	}
}
</pre >
</div>

<div id="apicanshu">        
<pre >
//访问路径
url:http://yinxiaoyou.com:8080/espeedYxyService/httpsendservice.action
//所属域名
httpdomain 例:21gmail.com
//帐号
httploginid 例:info
//aip认证码
httpaip 例:123456
//邮件收件人
httpto	例:274603467@qq.com	多个使用;号分割
//邮件发件人地址
httpfrom 例:274603467@qq.com
//邮件发件人姓名
httpfromname 例:张三
//回复人
httpreplyto 例:274603467@qq.com
//主题
httptitle	例:http发送邮件情况
//是否多主题
httpismanytitle	0:不使用1:使用
//内容
httpbody	注意:如果内容中包含图片则在要加入图片的地方加入:<img src='cid:IMG0'/>

</pre >        
</div>

<div id="apireturn">       
<pre  >
success:处理成功
exception:返回异常!
The user name or domain name or AIP error:域名,用户名,aip不正确
The sender is not empty:发送人为空
The subject is not empty:主题为空
The body is not empty:内容为空
The To is not empty:收件人为空
The total number of exceed the standard,How much:总量超标,剩余
The day number of exceed the standard,How much:日量超标,剩余
The month number of exceed the standard,How much:月量超标,剩余
The Single number of exceed the standard,How much:单次提交最大量超标,最大
</pre >  
</div>     
        </div>
    </div>

</body>
</html>