How to use SOAP to use SOAP to call the web services as the .NET Web Services, the bamboo. Many friends ask me how to call Web Services in other environments. The principle is actually very simple. Everyone knows that Web Services is based on SOAP protocol. Communication, naturally you can use SOAP to access Web Services in other environments. Below I will explain the calling process on a specific example. Development Environment: windows 2000 SOAP Tookit3.0 IIS using C # I wrote the following a Web Services: using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Diagnostics; Using system.web; using system.web.services;
namespace WebService_1 {public class Service1: System.Web.Services.WebService {string err_message; SqlDataAdapter my_adapter; DataSet ds = new DataSet (); DataSet ds1 = new DataSet (); DataSet ds_err; DataSet ds_value = new DataSet (); DataTable myDataTable Public service1 () {INITIALIZECMOMPONENT ();
Private system.data.sqlclient.sqlConnection SqlConnection1;
#Region Component Designer Generated Code // Web Server Designer The private icontainer component = null; ///
}
///
/// summary> protected override void Dispose (bool disposing) {if (disposing && components = null!) {Components.Dispose ();} base.Dispose (disposing);} #endregion [WebMethod] public DataSet Account_check ( string username, string password, string template, string org_nummer) {string sql; string cond; cond = org_nummer.Trim () Replace ( "", ","); sql = ". select * from Account where username = '" username " 'and password ='" password " '"; my_adapter = new SqlDataAdapter (sql, sqlConnection1); sqlConnection1.Open (); my_adapter.Fill (ds, "login"); sqlConnection1.Close (); if (ds.Tables [0] .Rows.Count == 0) {ds_err = new DataSet (); myDataTable = new DataTable ( "error"); DataColumn myDataColumn; DataRow myDataRow; myDataColumn = new DataColumn (); myDataColumn.DataType = System.Type.gettype ("System.String"); mydatacolumn.columnname = "error"; mydataable.columns.add (myDataColumn); mydatarow = myDataTable.newrow (); MyDataRow [ "Error"] = "status = 6"; myDataTable.Rows.Add (myDataRow); ds_err.Tables.Add (myDataTable); return ds_err;} // check if the customer have enough points err_message = Points_check (template); if (err_message = "!") {ds_err = new DataSet (); myDataTable = new DataTable ( "error"); DataColumn myDataColumn; DataRow myDataRow; myDataColumn = new DataColumn (); myDataColumn.DataType = System.Type.GetType ( " System.String "); mydatacolumn.columnname =" error ";
myDataTable.Columns.Add (myDataColumn); myDataRow = myDataTable.NewRow (); myDataRow [ "error"] = err_message; myDataTable.Rows.Add (myDataRow); ds_err.Tables.Add (myDataTable); return ds_err;} // Check if Belong To Some Rules, if NO, RETURN RESULT DS_ERR = rules_check (template, cond); Return DS_ERR;}}} ASP file: SOAPCLIENT.ASP