2.自己写WebService提供Add和getStudent服务。
2.自己写WebService提供Add和getStudent服务。
? 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=222221;"/>
Web.config System,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089" > type="System.Configuration.ClientSettingsSection,System, 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> ? (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |