Simple Web Service. namespace MyService { public class Service1 : System.Web.Services.WebService {

Similar documents
Classes in C# namespace classtest { public class myclass { public myclass() { } } }

Web Services in.net (2)

Tutorial 6 Enhancing the Inventory Application Introducing Variables, Memory Concepts and Arithmetic

Tutorial 5 Completing the Inventory Application Introducing Programming

Inheriting Windows Forms with Visual C#.NET

CALCULATOR APPLICATION

Web Services in.net (6) cont d

User-Defined Controls

This is the start of the server code

Web Services in.net (7)

ListBox. Class ListBoxTest. Allows users to add and remove items from ListBox Uses event handlers to add to, remove from, and clear list

In order to create your proxy classes, we have provided a WSDL file. This can be located at the following URL:

The contents of this document are directly taken from the EPiServer SDK. Please see the SDK for further technical information about EPiServer.

תוכנה 1 סמסטר א' תשע"א

Tutorial 19 - Microwave Oven Application Building Your Own Classes and Objects

מבוא למדעי המחשב תרגול 8 רשימה משורשרת כללית, Comparator

namespace Tst_Form { private: /// <summary> /// Required designer variable. /// </summary> System::ComponentModel::Container ^components;

Professional ASP.NET Web Services : Asynchronous Programming

מערכים שעור מס. 4 כל הזכויות שמורות דר ' דרור טובי המרכז האוניברסיטאי אריאל 1

Web Services in.net (6)

1. Windows Forms 2. Event-Handling Model 3. Basic Event Handling 4. Control Properties and Layout 5. Labels, TextBoxes and Buttons 6.

Convertor Binar -> Zecimal Rosu Alin, Calculatoare, An2 Mod de Functionare: Am creat un program, in Windows Form Application, care converteste un

Lampiran B. Program pengendali

תוכנה 1. תרגול מספר 11: Static vs. Dynamic Binding מחלקות מקוננות Nested Classes

- MEAN Stack חזרה. MongoDB - as the database Express - as the web framework AngularJS - as the frontend framework NodeJS- as the server platform

Instructions for writing Web Services using Microsoft.NET:

Operatii pop si push-stiva

The following list is the recommended system requirements for running the code in this book:

דף הדרכה ליצירת שרת/ לקוח עם GUI

מבוא לתכנות ב- JAVA תרגול 7

משתנים שעור מס. 2 כל הזכויות שמורות דר ' דרור טובי המרכז האוניברסיטאי אריאל 1

Sub To Srt Converter. This is the source code of this program. It is made in C# with.net 2.0.

PS2 Random Walk Simulator

CSC 330 Object-Oriented Programming. Encapsulation

Flag Quiz Application

CSIS 1624 CLASS TEST 6

תוכנה 1 * לא בהכרח בסדר הזה

תכנות מתקדם בשפת C משתנים

Practical Session No. 14 Topological sort,amortized Analysis

Advanced Lab in Computer Communications Meeting 1 Layers Model, Codes, Ethernet. Instructor: Tom Mahler

תוכנה 1 תרגול מספר 13

תוכנה 1 תרגול מספר 13

סכום (סדרת ערכים) אחרת - דוגמא: סכום-ספרות (num) אם < 10 num החזר 1 או אם = 0 = num החזר 0 public static int numofdigits (int num)

הנכות 1 םוכיס לוגרת 14 1

Arrays. Arrays: Declaration and Instantiation. Array: An Array of Simple Values

תוכנה 1 * לא בהכרח בסדר הזה

מבוא לתכנות תוכנית שעור מס. 1 1 דר' דרור טובי, המרכז האוניברסיטאי אריאל בשומרון.

תוכנה 1 * לא בהכרח בסדר הזה

מבוא לתכנות ב- JAVA תרגול 6

UNIT-3. Prepared by R.VINODINI 1

Polymorphism. Polymorphism. CSC 330 Object Oriented Programming. What is Polymorphism? Why polymorphism? Class-Object to Base-Class.

The Payroll User Interface: MODEL VIEW PRESENTER

לתיכנות עם MATLAB Lecture 5: Boolean logic and Boolean expressions

שאלה 1, סעיף ב )11 נק'(

LISTING PROGRAM. //Find the maximum and minimum values in the array int maxvalue = integers[0]; //start with first element int minvalue = integers[0];

An array can hold values of any type. The entire collection shares a single name

לתיכנות עם MATLAB Lecture 5: Boolean logic and Boolean expressions

קורס תכנות שיעור שני: שימוש במשתנים,

if (say==0) { k.commandtext = "Insert into kullanici(k_adi,sifre) values('" + textbox3.text + "','" + textbox4.text + "')"; k.

מבוא לתכנות ב- JAVA תרגול 5. Ipc161- practical session 5

XNA 4.0 RPG Tutorials. Part 11b. Game Editors

การสร างเว บเซอร ว สโดยใช Microsoft.NET

Processing Domain-Specific. Modeling Language. Fabien Latry, Julien Mercadal, and Charles Consel. Phoenix Research Group INRIA / LaBRI

Object oriented lab /second year / review/lecturer: yasmin maki

הנכות 1 םוכיס לוגרת 13 1

מבוא לתכנות ב- JAVA מעבדה 2

Tutorial 10. Introduction to C++ שימו

C:\homeworks\PenAttention_v13_src\PenAttention_v13_src\PenAttention4\PenAttention\PenAttention.cs 1 using System; 2 using System.Diagnostics; 3 using

<exp> ::= <define> <cexp> <define> ::= ( define <var-decl> <cexp> ) / DefExp(var:VarDecl, val:cexp)

LaserJet Enterprise M506

public class B { private int f = 0; public static void main(string[] args) { B b1 = new B(); B b2 = new B(); Object b3 = b1;

ממשק משתמש גרפי בעזרת SWT

הנכות 1 םוכיס לוגרת 13 1

You can call the project anything you like I will be calling this one project slide show.

IDoc based adapterless communication between SAP NetWeaver Application Server (SAP NetWeaver AS) and Microsoft BizTalk Server

Main Game Code. //ok honestly im not sure, if i guess its a class ment for this page called methodtimer that //either uses the timer or set to timer..

#pragma comment(lib, "irrklang.lib") #include <windows.h> namespace SuperMetroidCraft {

תרגול 4 פונקציות. מבנה של פונקציה: public static <return value type> <function name> (<arg1 type> <arg1>, <arg2 type> <arg2>, ) { <function body> }

KillTest *KIJGT 3WCNKV[ $GVVGT 5GTXKEG Q&A NZZV ]]] QORRZKYZ IUS =K ULLKX LXKK [VJGZK YKX\OIK LUX UTK _KGX

Visual Basic/C# Programming (330)

string spath; string sedifile = "277_005010X228.X12"; string sseffile = "277_005010X228.SemRef.EVAL0.SEF";

OGSI.NET UVa Grid Computing Group. OGSI.NET Developer Tutorial

The Open Core Interface SDK has to be installed on your development computer. The SDK can be downloaded at:

Blank Form. Industrial Programming. Discussion. First Form Code. Lecture 8: C# GUI Development

תור שימושים בעולם התוכנה

Avoiding KeyStrokes in Windows Applications using C#

תרגול 3 מערכים ופונקציות

בית הספר למדעי המחשב אוניברסיטת תל אביב תוכנה 1 תרגול מספר 9: הורשה מחלקות אבסטרקטיות חריגים

Visual Studio Windows Form Application #1 Basic Form Properties

מבוא למדעי המחשב הרצאה 2: ראשונים בשפת C

תוכנה 1. תרגול מס' 3 עבודה עם מחרוזות )Strings( מתודות )Methods( העברת פרמטרים

Mainly three tables namely Teacher, Student and Class for small database of a school. are used. The snapshots of all three tables are shown below.

IBSDK Quick Start Tutorial for C# 2010

תרשים המחלקות ותרשים העצמים

מבוא למדעי המחשב תירגול 3:

Your Company Name. Tel: Fax: Microsoft Visual Studio C# Project Source Code Output

עמוד 1 (תאריך ( âùéä ער äìàù בכל השאלות ניתן להניח שהקלט תקין. 100 íåëñ חורף :

Lucrare pentru colocviu de practică

and event handlers Murach's C# 2012, C6 2013, Mike Murach & Associates, Inc. Slide 1

LISTING PROGRAM. // // TODO: Add constructor code after the InitializeComponent() call. //

Transcription:

Simple Web Service WS פתיחת פרוייקט File New Project ASP.Net web service project - >http://localhost/webservice1 יצירת שירות המחשב חיבור וחילוק 2 מספרים : הטיפוסים הבסיסיים using System; איסוף וניהוף אוספי אובייטים using System.Collections; מימוש פונקציונליות של רכיבים ופקדים בזמן ריצה using System.ComponentModel; using System.Data; מידע ממקורות שונים ADOניהול using System.Diagnostics;, טיפול בהליכי מע ' ההפעלה,דיבוג \event\performance using System.Web; clientתקשורת \ server \ Http \httpserverutility using System.Web.Services; דרך פרוטוקלי אינטרנט סטנדרטיים WebServices \נגישות namespace MyService public class Service1 : System.Web.Services.WebService הורשה ממחלקת webservice public Service1() InitializeComponent(); פונקציית אתחול פקדים ורכיבים (שהוספנו) #region Component Designer generated code private void InitializeComponent() ה visual st מוסיף לכן את הגדרת הרכיבים #endregion protected override void Dispose( bool disposing ) מימוש פוהקציית dispose לשחרור אובייקטים הערות לקומפיילר HTTP המאפשר הכרזה על מתודה הנגישה דרך פרוטוקול Attribute [WebMethod] public int Add(int num1,int num2) מימוש הפונקציה לחישוב סכום return num1+num2; ניתן להוסיף מאפיינים : כגון תיאור הפונקציה [WebMethod(Description="This is a Div Funaction")] public double div(double num1,double num2) מיוש מתודה המבצעת חלוקה if (num2==0) בין שני מספרים כולל זריקת throw new Exception("Error:Divided by zero!!!"); חריג במקרה של חלוקה ב 0 else return num1/num2; [WebMethod(Description="This is a Div Funaction")] = True : BufferResponse כל הודעה תשמר ב buffer לפני שתישלח K16 = False בלבד (default=false) בשניות cach שמירת התוצאות ב : CachDuration : Description טקסט הסבר (default=false) שיוש במשתנים בנפרד לכל משתמש :מאשפר EnableSession : MassageName קביעת שם הפונקציה ב WSDL למנוע התנגשות שמות : TransactionOption יצירת טרנזקציות של כל COM+ הזכויות שמורות לדורון אמיר

ניתן לגשת ישירות אל השירות ע"י גלישה אל קובץ ה < asmx נוצר דף המכיל את פעולות השירות נבחר את המתודה Add ונקליד את המספרים לבדיקה נקבל את התוצאה בתצורת XML Client Side

כעת נפתח אפליקציית Win ובעזרתה נשלח פרמטרים אל השירות צור WinApplication הוסף ליישום Web Referebce צור proxy בצד הלקוח צור אובייקט התקשרות (1 (2 (3 (4

using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace ClientTestService1 /// <summary> /// Summary description for Form1. /// </summary> public class Form1 : System.Windows.Forms.Form private System.Windows.Forms.Button btn_div; private System.Windows.Forms.TextBox textbox1; private System.Windows.Forms.TextBox textbox2; private System.Windows.Forms.TextBox textbox3; private System.Windows.Forms.Label label1; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null; private System.Windows.Forms.Button btn_add; private System.Windows.Forms.Label label2; הגדרת משתנה מיוחס אל השירות// WS1; public localhost.service1 public Form1() InitializeComponent(); הקוד המיוצר מה Visual st protected override void Dispose( bool disposing ). #region Windows Form Designer generated code private void InitializeComponent() this.btn_add = new System.Windows.Forms.Button();.. this.btn_add.tabindex = 0; this.btn_add.text = "Add"; תגובה לאירוע click של האובייקט : btn Add קריאה לפונקציה btn Add Click this.btn_add.click += new System.EventHandler(this.btn_Add_Click); this.btn_div.click += new System.EventHandler(this.btn_Div_Click); האופרטור =+ מוסיף מתודות למופע של ה delegate

[STAThread] static void Main() Application.Run(new Form1()); private void Form1_Load(object sender, System.EventArgs e) this.ws1 = new localhost.service1(); יצירת מופע דרך ה proxy של הרכיב הנמצא בצד הלקוח private void btn_div_click(object sender, System.EventArgs e) double a,b,c; try a=double.parse(textbox1.text); b=double.parse(textbox2.text); c=ws1.div(a,b); textbox3.text=c.tostring(); המרת הפרמטרים ושליחתם אל הרכיב בזרת רכיב ה proxy העביר את הפרמטרים בפרוטוקול SOAP אל רכיב השרת המרת הערך המוחזר למחרוזת טקסט catch(exception err) MessageBox.Show(err.Message); לכידת השגיאה (אם קיימת ( private void btn_add_click(object sender, System.EventArgs e) int a,b,c; try a=int.parse(textbox1.text); b=int.parse(textbox2.text); c=ws1.add(a,b); textbox3.text=c.tostring(); catch(exception err) MessageBox.Show(err.Message);