ASP.NET webservice,查询天气预报,手机号码等
来源:互联网 发布:黑马程序员好找工作吗 编辑:程序博客网 时间:2024/05/17 01:39
web服务:
添加方法:
[WebMethod]//必须有
public int Add(int a,int b)
{
returna+b;
}
public Data GetStudent()
{
string str=System.ConigurationManager.
using(SqlConnection cnn=new SqlConnection())
{
using(SqlCommand cmm=cnn.CreateCommand())
{
cmm.CommandText="select*from student";
SqlDataAdapter da =new SqlDataAdapter(cmm);
DataSet ds =new DataSet();
da.Fill(ds);
return ds;
}
}
}
web服务的传输协议知识点:
HTTP-GET
在地址栏
<webService><protocols><add name="HttpGet"></protocols></webService>
HTTP-POST
SOAP
将WebService发布到服务器上:
调用上述加法(新建网站)(没有发布必须打开需要调用的网站)
protected void Button1_Click(object sender, EventArgs e)
{
localhost.WebService ws=new localhost.WebService();
this.TextBox3.Text = ws.Add(Convert.ToInt32(TextBox1.Text), Convert.ToInt32(TextBox2.Text)).ToString();
this.GridView1.DataSource=ws.GetStudent();
this.GridView1.DataBind();
}
天气预报:
protected void Page_Load(object sender, EventArgs e)
{
if(!this.IsPostBack)
{
cn.com.webxml.www.WeatherWebService wws=new cn.com.webxml.www.WeatherWebService();
this.DropDownList1.DataSource=wws.getSupportProvince();
this.DropDownList1.DataBind();
}
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
cn.com.webxml.www.WeatherWebService wws = new cn.com.webxml.www.WeatherWebService();
BindCity(wws);
}
private void BindCity(cn.com.webxml.www.WeatherWebService wws)
{
this.DropDownList2.Items.Clear();
string[] strs = wws.getSupportCity(this.DropDownList1.SelectedValue);
foreach (string str in strs)
{
this.DropDownList2.Items.Add(new ListItem(str.Substring(0, str.IndexOf("("))));
}
}
protected void Button2_Click(object sender, EventArgs e)
{
cn.com.webxml.www.WeatherWebService wws = new cn.com.webxml.www.WeatherWebService();
string[] strs = wws.getWeatherbyCityName(this.DropDownList2.SelectedValue);
this.Label1.Text = strs[0] + "," + strs[1] + "<br/>";
this.Label1.Text = "温度:" + strs[5] + "<br/>";
this.Label1.Text = "风:" + strs[7];
}
电话号码的查询:
protected void Button3_Click(object sender, EventArgs e)
{
cn.com.webxml.webservice.MobileCodeWS ws=new cn.com.webxml.webservice.MobileCodeWS ();
string strss = ws.getMobileCodeInfo(this.TextBox4.Text, this.TextBox5.Text);
this.Label2.Text = strss;
}
- ASP.NET webservice,查询天气预报,手机号码等
- ASP.NET WebService天气预报
- WebService开发--手机号码归属地查询和天气预报查询
- asp.net实现手机号码归属地查询
- asp.net实现手机号码归属地查询
- webservice查询天气预报
- .NET 查询天气预报的Webservice接口程序源代码
- webservice---手机号码归属地查询
- asp.net实现手机号码归属地查询,代码如下
- 免费的webservice接口(天气预报/IP查询/股票查询/手机归属地等)
- ASP.NET 判断手机号码
- asp.net 获取手机号码
- 利用WebService制作天气预报查询
- 通过一个天气预报案例学习asp.net WebService(基于asp.net MVC)
- asp.net 天气预报查寻
- .net使用WebService获取天气预报
- .net使用WebService获取天气预报
- Android天气预报,手机号码归属地,股市行情WEB服务 webservice
- js调用.net后台事件,和后台调用前台等方法总结
- List of colors (from wikipedia)
- 什么是创业实验田
- 用指定的编码(如UTF-8) 写文件
- 提笔忘字,亟须重视的电脑病
- ASP.NET webservice,查询天气预报,手机号码等
- Flex 图片阴影
- centos 5.4 升级php到5.3的方法
- (转)C语言中的位运算
- 非安装版_Tomcat不能手动启动解决
- SCP 命令详解
- 网站首页用户分析的四种类型
- linux中使用netstat命令
- 如何动态创建数据库表