Upload
rafe-kelley
View
269
Download
1
Embed Size (px)
Citation preview
www.renad.org
ContentsBuilding Web Services
כתב
אקת'ם חאג' יחיא
BuildingBuilding Web Web ServicesServices
www.renad.org
www.renad.org
ContentsBuilding Web Services
פתח את תוכנת Visual Studio לחץ על File->New->Web Site בחר את התבנית ASP.NET Web
Service בחר שם לפרויקט
www.renad.org
ContentsBuilding Web Services
הסר את הקבציםService.asmx -ו Service.cs
הוסף קובץ חדש מסוגWeb Service בשם Math.asmx
www.renad.org
ContentsBuilding Web Services
ו- Math.csוודא שהקובציםMath.asmx התווספו
לפרויקט
המבנה של הפרויקט ייראה כך:
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הוסף את הקוד הבא לקובץ שנפתח
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
www.renad.org
ContentsBuilding Web Services
]WebService(Namespace = "http://tempuri.org/")[
המלצה לשנות את מרחב השמות שנמצא כמאפיין
WSבראש מחלקת ה-
oהרץ את הפרויקט o בדוק אם כל המתודות נמצאות
בדף
www.renad.org
ContentsBuilding Web Services
לחיצה על הקישור Service Description
שבראש הדף תציג לנו שמתאר WSDLאת ה- WSאת ה-
www.renad.org
ContentsBuilding Web Services
יוצג לנו הדף הבאAddבלחיצה על שם המתודה
הכנס שני ערכים לתיבות הטקסט
כדי Invokeולחץ על להפעיל את המתודה
www.renad.org
ContentsBuilding Web Services
התוצאה היא XMLתמיד קובץ
זה הקובץ שמקבל WSהצרכן של ה-
www.renad.org
ContentsBuilding Web Services
o -מבנה הודעת ה Soap o בחלק העליון נמצא בין
השאר את הערכים שהמתודה מקבלת
o בחלק התחתון נמצא בין השאר את הערך
שהמתודה מחזירה