1、添加wenservice引用
http://XXXX/Webservice/SMSWebService.asmx
2、添加一个类,实现接口里面的方法(最好写在BLL中方便项目中调用)
public static SMSWebService.SMSWebService SendSMS()
{
SMSWebService.SMSWebService sendSMS = new SMSWebService.SMSWebService();
return sendSMS;
}
3、动态接口地址的实现
public static BigAntMessage.AntMessage BigAntSendBoard()
{
string strUrl = System.Configuration.ConfigurationManager.AppSettings["IBigAnt"];
strUrl += "/api/message.html?wsdl";
BigAntMessage.AntMessage sendBoard = new BigAntMessage.AntMessage(strUrl);
return sendBoard;
}
//调用接口实现功能
#region 获取未发送短信数据,并调用接口发送短信
/// <summary>
/// 发送短信
///</summary>
///<returns>0:失败,1:成功</returns>
[WebMethod(Description = "发送短信")]
publicstring SendSMS()
{
JYJ.OA.BLL.SMSWebService.SMSWebService sendSMS = new OA.BLL.SMSWebService.SMSWebService();
SYS_SMSSEND cSMSSend = new SYS_SMSSEND();
//获取所有未发送数据 string strReturn = "0";
IList<Hzjg.OA.Model.SYS_SMSSEND> list = cSMSSend.GetList(" where t.SENDSTATE=0", "");
foreach (var sms in list)
{
strReturn = sendSMS.SendSMS(sms.RECVPHONE, sms.SENDMSG, System.Configuration.ConfigurationManager.AppSettings["SMSKey"];
if (strReturn == "1")
{
sms.SENDSTATE = 1;
cSMSSend.Update(sms);
}
}
return strReturn;
}
#endregion
开发接口:
1、添加WebService1.asmx服务文件
2、开发接口方法