[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加入如下代码:
3.运行Run AS->Java Application 程序,就可以测试了!
备注:账号的注册地址为[url]http://218.94.58.243/web/[/url]
[/size]
//代码如下
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]