⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 apitest.java

📁 EMPP的接口包
💻 JAVA
字号:
/*
 * 创建日期 2005-12-14
 *
 * TODO 要更改此生成的文件的模板,请转至
 * 窗口 - 首选项 - Java - 代码样式 - 代码模板
 */
package test;

import com.wondertek.esmp.esms.empp.EMPPConnectResp;
import com.wondertek.esmp.esms.empp.EmppApi;


/**
 * @author chensheng
 * 
 * TODO 要更改此生成的类型注释的模板,请转至 窗口 - 首选项 - Java - 代码样式 - 代码模板
 */
public class ApiTest {

	public static void main(String[] args) {

		String host = "192.168.0.215";
		int port = 9981;
		String accountId = "555580001";
		String password = "cool1226";
		String serviceId = "555580001";

		

		EmppApi emppApi = new EmppApi();
		RecvListener listener = new RecvListener(emppApi);

		try {
			//建立同服务器的连接
			EMPPConnectResp response = emppApi.connect(host, port, accountId,
					password, listener);
			System.out.println(response);
			if (response == null) {
				System.out.println("连接超时失败");
				return;
			}
			if (!emppApi.isConnected()) {
				System.out.println("连接失败:响应包状态位=" + response.getStatus());
				return;
			}
		} catch (Exception e) {
			System.out.println("发生异常,导致连接失败");
			e.printStackTrace();
			return;
		}
		
//		发送短信
		if (emppApi.isSubmitable()) {
			
			//简单方式发送短信,支持长短信
			try{
				emppApi.submitMsgAsync("查出来是什么原因了么?",new String[]{"13800210021"},serviceId);
				
				//同步发送方式update 20060307
				//EMPPSubmitSMResp []  resp = emppApi.submitMsg(content,mobiles,serviceId);
				//System.out.println("resp result:"+resp[0].getResult());

			}catch (Exception e1) {
				e1.printStackTrace();
			} 
			
	//		详细设置短信的各个属性,不支持长短信
//			EMPPSubmitSM msg = (EMPPSubmitSM) EMPPObject
//					.createEMPP(EMPPData.EMPP_SUBMIT);
//			String mobile = "13564468230";
//			List dstId = new ArrayList();
//			dstId.add(mobile);
//
//			msg.setDstTermId(dstId);
//			msg.setSrcTermId(accountId);
//			msg.setServiceId(serviceId);
//
//			EMPPShortMsg msgContent = new EMPPShortMsg(
//					EMPPShortMsg.EMPP_MSG_CONTENT_MAXLEN);
//
//			try {
//				msgContent.setMessage("09939可以收发短信");
//				msg.setShortMessage(msgContent);
//				msg.assignSequenceNumber();
//				emppApi.submitMsgAsync(msg);
//
//			} catch (Exception e) {
//				e.printStackTrace();
//			}
			
		}

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -