ECT 7120 Distributed Systems and Software - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

ECT 7120 Distributed Systems and Software

Description:

Calling Web Services -- .aspx. Calling Web Services -- result. http://137.189.89.81/WebSite2/Default.aspx. 3. Application Sample with C ... – PowerPoint PPT presentation

Number of Views:54
Avg rating:3.0/5.0
Slides: 20
Provided by: pwc5
Category:

less

Transcript and Presenter's Notes

Title: ECT 7120 Distributed Systems and Software


1
ECT 7120 Distributed Systems and Software
  • Web Services and .NET Demonstration

2
Component needed
  • IIS (Internet Information Services, latest
    version 6.0)
  • .NET Framework (latest version 1.2)
  • Visual Studio .NET 2005

3
1. Creating Web Services with .NET
  • Step1 click New ? Web Site ? ASP .NET Web
    Service, choose the language you want. (Visual
    C, VB, Visual J...)
  • Step2 Right click Service1.asmx and select View
    Code to enter the code design window
  • Step3 Use ltWebMethod()gt 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
Create Web Services
5
Add Method in Web Services
6
Creating Web Services with .NET
  • Step4 click start to execute the web services
  • A browser will appear with the Add method
    displayed and hyperlinked
  • Click Add to open another browser to perform the
    add function
  • Type in two values (X and Y) then click invoke to
    get the result
  • The result will be returned in XML format
  • Students can try to browse the web service in the
    server
  • http//137.189.89.81/demo/Service.asmx

7
Execute the Web Services
http//137.189.89.81/demo/Service.asmx
8
Execute the Web Services
9
View XML Result in Browser
10
2. Calling Web Services with .NET
  • From local host
  • Create a new ASP .NET Web Application (say
    WebApplication1)
  • 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
  • Create a Web form interface
  • 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()

11
Calling Web Services -- C
12
Calling Web Services -- .aspx
13
Calling Web Services -- result
http//137.189.89.81/WebSite2/Default.aspx
14
3. Application Sample with C
  • Create a new Visual C Projects, says Window
    Form Application.
  • 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
  • Create a Dialog-based interface
  • Code
  • AddService ws
  • int result
  • result ws.Add (1, 2)
  • SystemWindowsFormsMessageBoxShow
    (SystemStringFormat("0", result))

15
Application Sample with C
16
Application Sample with C
17
Application Sample with C
18
(No Transcript)
19
Application Sample with C
Write a Comment
User Comments (0)
About PowerShow.com