งานนำเสนอกำลังจะดาวน์โหลด โปรดรอ

งานนำเสนอกำลังจะดาวน์โหลด โปรดรอ

Web Services Nipat J. Nipat J..

งานนำเสนอที่คล้ายกัน


งานนำเสนอเรื่อง: "Web Services Nipat J. Nipat J.."— ใบสำเนางานนำเสนอ:

1 Web Services Nipat J. Nipat J.

2 1. สร้าง web service Nipat J. Nipat J.

3 Steps: Nipat J. Nipat J.

4 Steps: Nipat J. Nipat J.

5 Steps: Nipat J. Nipat J.

6 Steps: Nipat J. Nipat J.

7 Steps: Nipat J. Nipat J.

8 Steps: Source code ในไฟล์ MathService.cs using System;
using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; /// <summary> /// Summary description for MathService /// </summary> [WebService(Namespace = " [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. // [System.Web.Script.Services.ScriptService] public class MathService : System.Web.Services.WebService { public MathService () { //Uncomment the following line if using designed components //InitializeComponent(); } Nipat J. Nipat J.

9 Steps: [WebMethod] public double Add(double a, double b) {
return (a + b); } public double Subtract(double a, double b) return (a - b); public double Multiply(double a, double b) return a * b; Nipat J. Nipat J.

10 Steps: Run โปรแกรมเพื่อทดสอบ Web Service [WebMethod]
public double Divide(double a, double b) { if (b == 0) return -1; return a / b; } Run โปรแกรมเพื่อทดสอบ Web Service Nipat J. Nipat J.

11 Steps: Nipat J. Nipat J.

12 Steps: Nipat J. Nipat J.

13 Steps: Nipat J. Nipat J.

14 2. สร้าง web page เพื่อทดสอบweb service
Nipat J. Nipat J.

15 Steps: Nipat J. Nipat J.

16 Steps: Nipat J. Nipat J.

17 Steps: Nipat J. Nipat J.

18 Steps: Nipat J. Nipat J.

19 Steps: Nipat J. Nipat J.

20 Steps: Nipat J. Nipat J.

21 Steps: Nipat J. Nipat J.

22 Steps: Nipat J. Nipat J.

23 Steps: สร้าง components ต่างๆ ในไฟล์ TestMathService.aspx
และกำหนด ID ของแต่ละ component ดังนี้ txtFirst txtSecond lblResult btnAdd btnSub btnMul btnDiv Nipat J. Nipat J.

24 Steps: Source code ในไฟล์ TestMathService.cs using System;
using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class TestMathService : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnAdd_Click1(object sender, EventArgs e) { localhost.MathService myMathService = new localhost.MathService(); double a = Convert.ToDouble(txtFirst.Text); double b = Convert.ToDouble(txtSecond.Text); double result = myMathService.Add(a,b); lblResult.Text = Convert.ToString(result); Nipat J. Nipat J.

25 Steps: protected void btnSub_Click(object sender, EventArgs e) {
localhost.MathService myMathService = new localhost.MathService(); double a = Convert.ToDouble(txtFirst.Text); double b = Convert.ToDouble(txtSecond.Text); double result = myMathService.Subtract(a, b); lblResult.Text = Convert.ToString(result); } protected void btnMul_Click(object sender, EventArgs e) double result = myMathService.Multiply(a, b); Nipat J. Nipat J.

26 Steps: Run โปรแกรมเพื่อทดสอบการเรียกใช้ Web Service
protected void btnDiv_Click(object sender, EventArgs e) { localhost.MathService myMathService = new localhost.MathService(); double a = Convert.ToDouble(txtFirst.Text); double b = Convert.ToDouble(txtSecond.Text); double result = myMathService.Divide(a, b); lblResult.Text = Convert.ToString(result); } Run โปรแกรมเพื่อทดสอบการเรียกใช้ Web Service Nipat J. Nipat J.

27 Steps: Nipat J. Nipat J.

28 Exercise – การสร้างและการเรียกใช้งาน web service
1.1 Celsius เป็น Fahrenheit 1.2 Fahrenheit เป็น Celsius 2. สร้าง web application สำหรับทดสอบ web service ตัวอย่าง Nipat J. Nipat J.

29 3. สร้าง web page เพื่อทดสอบpublic web services
Nipat J. Nipat J.

30 Steps: Link ของ web service ที่จะใช้ทดสอบ
Nipat J. Nipat J.

31 Steps: 1. สร้างไฟล์ TestPtt.aspx เพื่อทดสอบ web service ของ PTT
Nipat J. Nipat J.

32 Steps: 2. Add Web Reference Nipat J. Nipat J.

33 Steps: 2. Add Web Reference Nipat J. Nipat J.

34 Steps: แสดงโครงสร้างของ service ในโฟล์เดอร์ App_WebReferences Nipat J.

35 Steps: 3. สร้าง Label ที่มี ID = “lblDisplay” ในไฟล์ TestPtt.aspx ดังนี้ Nipat J. Nipat J.

36 Steps: 4. เพิ่ม code ในไฟล์ TestPtt.aspx.cs ดังนี้ Nipat J. Nipat J.

37 Steps: 4. เพิ่ม code ในไฟล์ TestPtt.aspx.cs ในเมททอด Page_Load() ดังนี้ using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class TestPtt : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) com.pttplc. pttInfo = new com.pttplc. lblDisplay.Text = pttInfo.CurrentOilPrice("th"); } Nipat J. Nipat J.

38 Steps: 5. Run โปรแกรมเพื่อทดสอบการใช้งาน web service Nipat J. Nipat J.

39 Exercise – การเรียกใช้งาน web service (public)
สร้าง web application เพื่อเรียกการใช้งาน services ต่างๆของกรมสรรพากร ทดสอบ -- Nipat J. Nipat J.

40 Exercise – การเรียกใช้งาน web service (public)
Nipat J. Nipat J.

41 แบบทดสอบ web service ให้สร้าง web service ชื่อ Quadratic.asmx และ web page ชื่อ TestQuadratic.aspx สำหรับทดสอบสมการ Quadratic (ax2 + bx + c = 0) 4x2 + 6x+ 2 = easy 4x2 + 8x+ 2 = ??? Nipat J. Nipat J.

42 แบบทดสอบ web service ให้สร้าง web service ชื่อ Distance.asmx และ web page ชื่อ TestDistance.aspx สำหรับทดสอบระยะทางระหว่าง 2 พิกัดบนระนาบ x, y (X2,y2) ? m. (X1,y1) Nipat J. Nipat J.


ดาวน์โหลด ppt Web Services Nipat J. Nipat J..

งานนำเสนอที่คล้ายกัน


Ads by Google