/** 方法名称:httpUninit 作者: zhang dong 00199735 创建时间:2012-08-30 方法描述:http反初始化 输入参数: 备注: */ public int httpUninit() { if (httpSdk != null) { int iRet = httpSdk.HttpUninit(); Logger.debug(EspaceService.TAG, "HttpManager:httpUninit:" + iRet); } return 0; }
/** * 方法名称:httpUploadFile 作者: zhang dong 00199735 创建时间:2012-08-30 方法描述:上传文件 输入参数:filepath 文件路径 备注: */ private int httpUploadFile(int handle, String method, String url, String body, String filePath) { StringBuffer strParam = new StringBuffer(); strParam.append("<httpsdk>"); strParam.append("<handle>").append(handle).append("</handle>"); strParam.append("<method>").append(method).append("</method>"); strParam.append("<url>").append(url).append("</url>"); strParam.append("<heads>"); // strParam.append("<Content-Type>").append("text/xml") // .append("</Content-Type>"); // strParam.append("<Cache-Control>").append("non-cache") // .append("</Cache-Control>"); // strParam.append("<User-Agent>") // .append("Mozilla/4.0 (compatible; MSIE 60; Windows.NT)") // .append("</User-Agent>"); // strParam.append("<Accept-Encoding>").append("gzip, deflate") // .append("</Accept-Encoding>"); strParam.append("<Connection>").append("Keep-Alive").append("</Connection>"); // strParam.append("<Accept>").append("*/*").append("</Accept>"); strParam.append("</heads>"); // strParam.append("<body>").append(body).append("</body>"); strParam.append("<filepath>").append(filePath).append("</filepath>"); strParam.append("<needprogress>").append("1").append("</needprogress>"); strParam.append("</httpsdk>"); int iRet = httpSdk.HttpUploadFile(strParam.toString()); Logger.beginDebug(EspaceService.TAG).p("HttpManager:httpUploadFile:" + iRet).end(); return iRet; }
/** 方法名称:createHandle 作者: zhang dong 00199735 创建时间:2012-08-30 方法描述:创建http句柄 输入参数: 备注: */ public String httpCreateHandle( String hostip, int port, int tlsmode, int authMode, String account, String password, String fullnumber) { StringBuffer strParam = new StringBuffer(); strParam.append("<httpsdk>"); strParam.append("<hostip>").append(hostip).append("</hostip>"); strParam.append("<hostport>").append(port).append("</hostport>"); strParam.append("<tlsmode>").append(tlsmode).append("</tlsmode>"); strParam.append("<authmode>").append(authMode).append("</authmode>"); if (authMode != HttpParam.EN_AUTH_MODE.EN_AUTH_CLOSE) { strParam.append("<authpara>"); strParam.append("<username>").append(account).append("</username>"); strParam.append("<password>").append(password).append("</password>"); if (!StringUtil.isStringEmpty(fullnumber)) { strParam.append("<cnonce>").append(fullnumber).append("</cnonce>"); } strParam.append("</authpara>"); } strParam.append("</httpsdk>"); String strRet = httpSdk.HttpCreateHandle(strParam.toString()); return strRet; }
/** * httpSdk 初始化 * * @param logPath */ public void initHttpSdk(String logPath) { this.logPath = logPath; // 全局唯一,只初始化一次 if (httpSdk == null) { Logger.debug(EspaceService.TAG, "httpsdk init:logPath:" + logPath); httpSdk = HttpSdk.registerCallback(this); } }
/** * 方法名称:httpInit 作者: zhang dong 00199735 创建时间:2012-08-30 方法描述:http初始化 输入参数: 备注: * * @param handlenum */ private int httpInit(int logLevel, int logSize, String logPath, int handlenum) { StringBuffer strParam = new StringBuffer(); strParam.append("<httpsdk>"); strParam.append("<level>").append(logLevel).append("</level>"); strParam.append("<size>").append(logSize).append("</size>"); strParam.append("<logpath>").append(logPath).append("</logpath>"); strParam.append("<handlenum>").append(handlenum).append("</handlenum>"); strParam.append("<usesvn>").append("0").append("</usesvn>"); // svn strParam.append("<usesvnfile>").append("1").append("</usesvnfile>"); // svn strParam.append("</httpsdk>"); int iRet = httpSdk.HttpInit(strParam.toString()); Logger.debug(EspaceService.TAG, "httpSdk init:ret" + iRet + ")"); init = true; return iRet; }
/** 方法名称:httpReleaseHandle 作者: zhang dong 00199735 创建时间:2012-08-30 方法描述:http句柄释放 输入参数: 备注: */ private int httpReleaseHandle(int handle) { int iRet = httpSdk.HttpReleaseHandle(handle); return iRet; }