When you add a Web reference, Visual Studio .Net is actually creating a wrapper class that encapsulates all of the SOAP code. This section talks about doing this. Figure 14.7 shows how to add a Web Reference, Figure 14.8 shows the Web Reference in the Solution Explorer Window, and Figure 14.9 shows using a Web Reference from an ASP.NET application, and Figure 14.10 shows using a Web Reference from a stand-alone application. private void Page_Load(object sender, System.EventArgs { if( !IsPostBack ) { com.dotnet_networking.www.Service1 svc = new com.dotnet_networking.www.Service1(); string[] Names = svc.GetSalesForce(); NameList.DataSource = Names; NameList.DataBind(); } } private void Button1_Click(object sender, System.EventArgs { com.dotnet_networking.www.Service1 svc = new com.dotnet_networking.www.Service1(); double dCommissionRate = svc.GetCommissionRate( NameList.SelectedItem.Value ); CommissionRate.Text = "Commission Rate: " + Convert.ToString( dCommissionRate ) + "%"; } private void button1_Click(object sender, System.EventArgs { com.dotnet_networking.www.Service1 svc = new com.dotnet_networking.www.Service1(); PharmInfo.Text = svc.GetPharm( NDC.Text ); } Figure 14.7. When You Add a Web Reference, the Web Service Will Return a WSDL Contract.Figure 14.8. The Web Reference Shows Up in the Solution Explorer Window.Figure 14.9. This Application Shows How Easy It Is to Use a Web Service from an Application.Figure 14.10. This C# Windows Application Uses a Web Service Easily. |