WebService client application method

Source: Internet
Author: User
The. NET platform has built-in support for Web services, including the construction and use of Web services.
Unlike other development platforms, you can use the. NET platform to develop Web services without other tools or SDKs .. NET Framework itself fully supports Web services, including server-side request processors and support for sending and receiving SOAP messages to clients. This article will show you how to use. NET to create and use Web services.
1. Create a Web service in. NET
To create a Web service in. NET, you only need to select "file/add new project" in your solution. The dialog box shown in Figure 1 is displayed:

Figure 1
In this box, select "Web Service" and specify the name. Vs. Net will create a default webservice framework for you. You can create the required webservice method as needed.
The following code returns the webservice method of all employee information from the northwind database employees of SQL server 2000.
[WebMethod]
Public string getEmployees ()
{
String cnstr = "server = njim01; database = northwind; uid = sa; pwd = 64084888 ;";
String rsString;
SqlConnection cn = new SqlConnection (cnstr );
SqlDataAdapter cmd = new SqlDataAdapter ("select * from employees", cn );
DataSet ds = new DataSet ();
DataTable tbl;
Cmd. Fill (ds, "employees ");
Tbl = ds. Tables ["employees"];
RsString = "<table border =" 0 "bgcolor =" blue "cellpadding =" 1"
Cellspacing = "1"> <tr bgcolor = "white"> ";
For (int I = 0; I <= ds. Tables ["employees"]. Columns. Count-1; I ++)
{
RsString + = "<td>" + ds. Tables ["employees"]. Columns [I]. ColumnName + "</td> ";
}
RsString + = "</tr> ";
For (int I = 0; I <tbl. Rows. Count; I ++)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.