Docstoc

dotnet_demo

Document Sample
dotnet_demo Powered By Docstoc
					.NET Demo

A.       Building Web services (just see the demo)


1.       click File  NewProject and select Visual Basic Projects and ASP .NET Web
         Service, the type the appropriate path and folder name
2.       Right click Service1.asmx and select View Code to enter the code design
         window
3.       Use <WebMethod()> to add new function (place Public before the function
         procedure)

     [WebMethod]

     public int Add(int x, int y)

     {     int result;

           result = x + y;

           return result;

     }



4.       ***Click start to execute the web services
(Students can try to browse the web service in the server)
http://137.189.89.81/demo/Service.asmx




                                                                                      1
B.  Calling Web Services with ASP.NET (see demo)
1.  Create a new ASP .NET Web Application (say WebSite1)
    [New  Web Site  ASP .NET Web Site]
2. Right click “App_WebReferences” and select “Add Web Reference…”
    Type in the appropriate path where the Web Service is located
    http://137.189.89.81/demo/Service.asmx
3. Right click WebForm1.aspx and select View Code to enter the code design
window


In aspx.cs
     protected void Button1_Click(object sender, EventArgs e)

     {

         if ((this.tbX.Text != "") && (this.tbY.Text != ""))

         {

             Addition.Service service = new Addition.Service();

             this.lbResult.Text = service.Add(int.Parse(this.tbX.Text),

             int.Parse(this.tbY.Text)).ToString();

         }

     }



http://137.189.89.81/WebSite2/Default.aspx




                                                                             2
C.     *** Calling Web Services with C++ application (Done by students)
1.     Open Visual Studio .NET 2005
2.     Create a new Visual C++ Projects
       [New  Project  Window Form Application  the type the appropriate path
       and folder name]
       Create a Dialog-based interface
3.     Right click the project name and select “Add Web Reference…”
       Type in the appropriate path where the Web Service is located
       http://137.189.89.81/demo/Service.asmx
4.     Toolbox  jet the Button  double click the button  add the following code
Code
                          Add::Service ws;

                          int result;

                          // YOU MUST USE THE METHOD U WISH TO ACCESS HERE.

                          result = ws.Add (1, 2);

                          System::Windows::Forms::MessageBox::Show

(System::String::Format("{0}", result));




                                                                                     3

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:3
posted:11/20/2011
language:English
pages:3