webservice问题请教
public class PhoneMsg : System.Web.Services.WebService { [DllImport("sms.dll", EntryPoint = "Sms_Connection")] public static extern uint Sms_Connection(string CopyRight, uint Com_Port, uint Com_BaudRate, out string Mobile_Type, out string CopyRightToCOM); [DllImport("sms.dll", EntryPoint = "Sms_Disconnection")] public static extern uint Sms_Disconnection(); [DllImport("sms.dll", EntryPoint = "Sms_Send")] public static extern uint Sms_Send(string Sms_TelNum, string Sms_Text); public PhoneMsg() { } // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。 // [System.Web.Script.Services.ScriptService] public class Service1 : System.Web.Services.WebService { [WebMethod] /*public string HelloWorld() { return "Hello World"; }*/ [SoapRpcMethod(Action = "http://www.wapasp.net/SendMessage", RequestNamespace = "http://www.wapasp.net/")] public string SendMessage(string sPhoneNum, string sContent) { String TypeStr = ""; String CopyRightToCOM = ""; String CopyRightStr = "//参考//"; try { if (Sms_Connection(CopyRightStr, 1, 9600, out TypeStr, out CopyRightToCOM) == 1) ///5为串口号,0为红外接口,1,2,3,...为串口 { string[] sPhoneArr = sPhoneNum.Split(','); for (int i = 0; i < sPhoneArr.Length; i++) { [color=#FF0000]Sms_Send(sPhoneArr, sContent);[/color] } //Sms_Send("13523661507", "aaaaaa"); Sms_Disconnection(); return "发送成功!"; } } catch (Exception ex) { return ex.ToString(); } return "发送失败!"; //return sPhoneNum + ":" + sContent; } } } }
[解决办法]
第一个没看到代码,第二个你需要用循环调用 Sms_Send
foreach(string phone in sPhoneArr)
Sms_Send(phone, sContent);