新浪短信接口新浪短信接口

private void Button1_Click(object sender, System.EventArgs e)
  {
   Add.Service Adds = new web.Add.Service();
   int c = Adds.add(Convert.ToInt32(TextBox1.Text),Convert.ToInt32(TextBox2.Text));
   Label1.Text=c.ToString();
  

  /*截取处于开始字符串和结束字符串中间的字符串,尤其适合得到处于xml标签之间的字符串内容;
  private string GetSubString(string mainString,string startString,string endString)
  {
   int start = mainString.IndexOf(startString);
   int end = mainString.IndexOf(endString);
   if (start<0||end<0)
   {
    return null;
   }
   else
   {
    string result = mainString.Substring(start+startString.Length,end-start-startString.Length);
    return result;
   }
  }

  其中mainString为子串,startString为起始标签,endString为结束标签.具体调用如下:

  string start = "<Message>";
  string end = "</Message>";
  string mainString = WebServiceName.SendXml(parameter...);
  string result = GetSubString(mainString,start,end);

  然后用MessageBox显示出来,发短信的用户就知道是否发送成功了.
         MessageBox.Show(result+"!");//加一个感叹号,漂亮一点:)
        
  该资源的该问地址为:http://smsinter.sina.com.cn/ws/smswebservice0101.wsdl,这是一个WSDL文件格式.
  您可以直接在您的VS.NET环境中直接添加Web引用,把该地址输入即可。

  该Web Service就只有一个方法,即string sendXml(carrier,userid,password,mobilenumber,content,msgtype)。
  各个参数全部为string类型,其含义基本如下(可能不正确)。

  carrier:运营商名称,这里面可以随便输,不过似乎没有任何显示,不知道里面有没有其它奥秘。
  userid:您在新浪无线上注册的手机ID,即http://sms.sina.com.cn
  password:您在新浪无线上注册手机时所使用的密码。
  mobilenumber:对方的手机号码;
  content:发送短消息的内容;
  msgtype:发送短消息的类型,我估计支持彩信,不过我目前仅使用文本短信方式,似乎随便输什么都可以,我使用的是“Text”。
  */
  }

 

http://smsinter.sina.com.cn/ws/smswebservice0101.wsdl

<?xml version="1.0" encoding="UTF-8" ?>

- < definitions name =" SMSWS " targetNamespace =" http://outlook.microsoft.com/add-ins/SMS/wsdl/ " xmlns:wsdlns =" http://outlook.microsoft.com/add-ins/SMS/wsdl/ " xmlns:typens =" http://outlook.microsoft.com/add-ins/SMS/type " xmlns:soap =" http://schemas.xmlsoap.org/wsdl/soap/ " xmlns:xsd =" http://www.w3.org/2001/XMLSchema " xmlns:stk =" http://schemas.microsoft.com/soap-toolkit/wsdl-extension " xmlns =" http://schemas.xmlsoap.org/wsdl/ ">
- < types >
  < schema targetNamespace =" http://outlook.microsoft.com/add-ins/SMS/type " xmlns =" http://www.w3.org/2001/XMLSchema " xmlns:SOAP-ENC =" http://schemas.xmlsoap.org/soap/encoding/ " xmlns:wsdl =" http://schemas.xmlsoap.org/wsdl/ " elementFormDefault =" qualified " />
  </ types >
- < message name =" SMSWebService.sendXml ">
  < part name =" Carrier " type =" xsd:string " />
  < part name =" Id " type =" xsd:string " />
  < part name =" Password " type =" xsd:string " />
  < part name =" ToMobile " type =" xsd:string " />
  < part name =" Message " type =" xsd:string " />
  < part name =" MsgType " type =" xsd:string " />
  </ message >
- < message name =" SMSWebService.sendXmlResponse ">
  < part name =" Result " type =" xsd:string " />
  </ message >
- < portType name =" SMSWebServiceSoapPort ">
- < operation name =" sendXml " parameterOrder =" Carrier Id Password ToMobile Message MsgType ">
  < input message =" wsdlns:SMSWebService.sendXml " />
  < output message =" wsdlns:SMSWebService.sendXmlResponse " />
  </ operation >
  </ portType >
- < binding name =" SMSWebServiceSoapBinding " type =" wsdlns:SMSWebServiceSoapPort ">
  < stk:binding preferredEncoding =" UTF-8 " />
  < soap:binding style =" rpc " transport =" http://schemas.xmlsoap.org/soap/http " />
- < operation name =" sendXml ">
  < soap:operation soapAction =" http://outlook.microsoft.com/add-ins/SMS/action/SMSWebService.sendXml " />
- < input >
  < soap:body use =" encoded " namespace =" http://outlook.microsoft.com/add-ins/SMS/message/ " encodingStyle =" http://schemas.xmlsoap.org/soap/encoding/ " />
  </ input >
- < output >
  < soap:body use =" encoded " namespace =" http://outlook.microsoft.com/add-ins/SMS/message/ " encodingStyle =" http://schemas.xmlsoap.org/soap/encoding/ " />
  </ output >
  </ operation >
  </ binding >
- < service name =" SMSWS ">
- < port name =" SMSWebServiceSoapPort " binding =" wsdlns:SMSWebServiceSoapBinding ">
  < soap:address location =" http://202.108.35.168/cgi-bin/ws/smswebservice0101 " />
  </ port >
  </ service >
  </ definitions >
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值