WebService提供Add和getStudent服务(IIS发布)
来源:互联网 发布:华为java编码规范 编辑:程序博客网 时间:2024/06/05 02:13
-------------WebService1.asmx.cs-----------------
public class WebService1 : System.Web.Services.WebService
{
[WebMethod]
public int Add(int a, int b)
{
return a + b;
}
[WebMethod]
public DataSet GetStudent()
{
string constr = ConfigurationManager.ConnectionStrings["studentConstr"].ConnectionString;
string sql = "select * from student";
SqlDataAdapter adapter = new SqlDataAdapter(sql, constr);
DataSet ds = new DataSet();
adapter.Fill(ds);
return ds;
}
}
==========================Web.config==========================
<configuration>
<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
</protocols>
</webServices>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<connectionStrings>
<add name="studentConstr" connectionString="data source=.;initial catalog=student;user
id=sa;password=111111;"/>
</connectionStrings>
</configuration>
-------WebAddStudent.aspx前台---------------
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
+
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Xonclick="Button1_Click" Text="Button" />
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<br />
<br />
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</div>
</form>
</body>
-------WebAddStudent.aspx.cs后台------------
protected void Button1_Click(object sender, EventArgs e)
{
localhost.WebService1 ws=new localhost.WebService1();
this.TextBox3.Text= ws.Add(Convert.ToInt32(this.TextBox1.Text),Convert.ToInt32
(this.TextBox2.Text)).ToString();
this.GridView1.DataSource = ws.GetStudent();
this.GridView1.DataBind();
}
==========================Web.config==========================
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup,
System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="userWebService.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<applicationSettings>
<userWebService.Properties.Settings>
<setting name="userWebService_localhost_WebService1" serializeAs="String">
<value>http://localhost:1095/WebService1.asmx</value>
</setting>
</userWebService.Properties.Settings>
</applicationSettings>
</configuration>
- WebService提供Add和getStudent服务(IIS发布)
- 2.自己写WebService提供Add和getStudent服务。
- IIS 发布Webservice问题
- 使用VS2010创建WebService 和IIS发布及一些常见问题
- iis 发布报表服务
- IIS 发布webService简单总结
- C#发布Webservice到IIS
- ArcEngine发布WebService服务
- Aixs2发布webservice服务
- WebService详解-服务发布
- cxf发布webservice 服务
- Axis2发布WebService服务
- dubbo发布webservice服务
- dubbo发布webservice服务
- 1.1 发布webservice 服务
- C#WebService发布以及IIS发布
- 最简的restful webservice实现,提供get和post服务(提供war包下载)
- 解决wince与主机webservice的连接和访问问题?webservice的IIS发布问题?
- jsonlib json,xml,object 互转
- Ramdisk文件系统的制作与调试运行
- ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
- UITabBarController的使用总结
- IOS之UILabel显示内容自动换行
- WebService提供Add和getStudent服务(IIS发布)
- 【BZOJ1033】[ZJOI2008]杀蚂蚁antbuster
- 6个有用的MySQL语句
- modbus源代码
- 为网站添加安全机制,windows与Form验证。
- 探索Lua5.2内部实现:虚拟机指令(4) Table
- Fancybox的API和配置选项说明
- 制作客户端邮件发送系统(winform版)
- 剖析solr实用性