企信通手机短信平台

[size=medium]//就是调用企信通的WebService接口,不过,需要账号和密码,也就说需要MOMEY的
//代码如下
1.首先要加入需要的Jar包,自己到去下载“axis.jar”、“commons-discovery-0.2.jar”、“commons-logging-1.0.4.jar”、“commons-net-1.4.1.jar”、“geronimo-spec-jaxrpc-1.1-rc4.jar”、“sendMsg_jdk1.6.jar”、“smslib-3.3.3.jar”;
2.创建一个servlet加入如下代码:
package servlet;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;

public class CodeService {

public static void main(String args[])
{
String ip = "218.94.58.243"; /*短信平台ip地址*/
String dbName = "mas";
String dbPort = "9005";
String loginName = "你的账号";
String loginPwd = "你的密码";
String apiCode = "webservice";

String[] mobiles = new String[1];
mobiles[0] = "发送的手机号码";
String content = "早上好";
String report = "早上好";

long smId = 10;
int result = 2;
/*下面是调用Webservice Init方法*/
try
{
String endpoint = "http://218.94.58.243/SMS_BlueWings/SMS_BlueWingsInfo.asmx?wsdl";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName("init");
result = Integer.parseInt("" + call.invoke(new Object[]{ip, dbName, dbPort,loginName, loginPwd}));
}catch(Exception e)
{
result = 12;
}
if (result == 0)
{
/*如果Init成功,尝试发送手机短信。*/
System.out.print("Init成功!");

/*下面是调用sendSM方法发送短信*/
try
{
String endpoint = "http://218.94.58.243/SMS_BlueWings/SMS_BlueWingsInfo.asmx?wsdl";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName("sendSM");
result = Integer.parseInt("" + call.invoke(new Object[]
{apiCode, loginName, loginPwd, mobiles, content, smId,
""}));
}catch(Exception e)
{
result = 7;
}


/*显示手机信息是否发送成功。*/
if (result == 0)
{
System.out.println(report + " " + "发送成功!");
}
else
System.out.println(report + " " + "发送失败!");


/*下面是短信发送完毕,调用release方法释放数据库连接。*/
try
{
String endpoint = "http://218.94.58.243/SMS_BlueWings/SMS_BlueWingsInfo.asmx?wsdl";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName("release");
result = Integer.parseInt("" + call.invoke(new Object[]{}));
}catch(Exception e)
{
result = 7;
}
}
else
System.out.println("Init失败!");
}

}


3.运行Run AS->Java Application 程序,就可以测试了!

备注:账号的注册地址为[url]http://218.94.58.243/web/[/url]
[/size]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值