11
www.renad.o rg Contents Building Web Services בבב בבב'ב בבב' בבבבBuilding Building Web Web Services Services www.renad.org

Www.renad.org Contents Building Web Services כתב אקת'ם חאג' יחיא BuildingWeb Services Building Web Services

Embed Size (px)

Citation preview

Page 1: Www.renad.org Contents Building Web Services כתב אקת'ם חאג' יחיא BuildingWeb Services Building Web Services

www.renad.org

ContentsBuilding Web Services

כתב

אקת'ם חאג' יחיא

BuildingBuilding Web Web ServicesServices

www.renad.org

Page 2: Www.renad.org Contents Building Web Services כתב אקת'ם חאג' יחיא BuildingWeb Services Building Web Services

www.renad.org

ContentsBuilding Web Services

פתח את תוכנת Visual Studio לחץ על File->New->Web Site בחר את התבנית ASP.NET Web

Service בחר שם לפרויקט

Page 3: Www.renad.org Contents Building Web Services כתב אקת'ם חאג' יחיא BuildingWeb Services Building Web Services

www.renad.org

ContentsBuilding Web Services

הסר את הקבציםService.asmx -ו Service.cs

הוסף קובץ חדש מסוגWeb Service בשם Math.asmx

Page 4: Www.renad.org Contents Building Web Services כתב אקת'ם חאג' יחיא BuildingWeb Services Building Web Services

www.renad.org

ContentsBuilding Web Services

ו- Math.csוודא שהקובציםMath.asmx התווספו

לפרויקט

המבנה של הפרויקט ייראה כך:

Page 5: Www.renad.org Contents Building Web Services כתב אקת'ם חאג' יחיא BuildingWeb Services Building Web Services

www.renad.org

ContentsBuilding Web Services

using System;using System.Web;using System.Web.Services;using System.Web.Services.Protocols;

public class Math : System.Web.Services.WebService {

public Math () { }

[WebMethod] public decimal Add (decimal num1,decimal num2) { return num1+num2; {

o לחץ לחיצה כפולה על הקובץ Math.csoהוסף את הקוד הבא לקובץ שנפתח

Page 6: Www.renad.org Contents Building Web Services כתב אקת'ם חאג' יחיא BuildingWeb Services Building Web Services

www.renad.org

ContentsBuilding Web Services

[WebMethod] public decimal Sub (decimal num1, decimal num2) { return num1 - num2; }

[WebMethod] public decimal Mult (decimal num1, decimal num2) { return num1 * num2; }

[WebMethod] public decimal Div (decimal num1, decimal num2) { return num1 / num2; }}

המשך לקוד של המחלקה Math.cs

Page 7: Www.renad.org Contents Building Web Services כתב אקת'ם חאג' יחיא BuildingWeb Services Building Web Services

www.renad.org

ContentsBuilding Web Services

]WebService(Namespace = "http://tempuri.org/")[

המלצה לשנות את מרחב השמות שנמצא כמאפיין

WSבראש מחלקת ה-

oהרץ את הפרויקט o בדוק אם כל המתודות נמצאות

בדף

Page 8: Www.renad.org Contents Building Web Services כתב אקת'ם חאג' יחיא BuildingWeb Services Building Web Services

www.renad.org

ContentsBuilding Web Services

לחיצה על הקישור Service Description

שבראש הדף תציג לנו שמתאר WSDLאת ה- WSאת ה-

Page 9: Www.renad.org Contents Building Web Services כתב אקת'ם חאג' יחיא BuildingWeb Services Building Web Services

www.renad.org

ContentsBuilding Web Services

יוצג לנו הדף הבאAddבלחיצה על שם המתודה

הכנס שני ערכים לתיבות הטקסט

כדי Invokeולחץ על להפעיל את המתודה

Page 10: Www.renad.org Contents Building Web Services כתב אקת'ם חאג' יחיא BuildingWeb Services Building Web Services

www.renad.org

ContentsBuilding Web Services

התוצאה היא XMLתמיד קובץ

זה הקובץ שמקבל WSהצרכן של ה-

Page 11: Www.renad.org Contents Building Web Services כתב אקת'ם חאג' יחיא BuildingWeb Services Building Web Services

www.renad.org

ContentsBuilding Web Services

o -מבנה הודעת ה Soap o בחלק העליון נמצא בין

השאר את הערכים שהמתודה מקבלת

o בחלק התחתון נמצא בין השאר את הערך

שהמתודה מחזירה