1 UCN 2012 Why use distributed (client / server) applications? To connect tiers within the same application... –client & server is both.NET assemblies.

Slides:



Advertisements
Similar presentations
Indigo Jonathan Turnbull Nick Cartwright Ivan Konontsev Chris Bright.
Advertisements

Michael S. Chan xLM Solutions, LLC
GETTING STARTED WITH WINDOWS COMMUNICATION FOUNDATION 4.5 Ed Jones & Grey Guindon.
WCF Intro Scott Reed Owner - Brain Hz Software Instructor – DevelopMentor
Web Services Darshan R. Kapadia Gregor von Laszewski 1http://grid.rit.edu.
Zoiner Tejada Hershey Technologies. About Zoiner Tejada.
 Introduction  WCF Definition  WCF Architecture  Implementation  WCF Demo Overview.
1 Nordjyllands Erhvervakademi Windows Communication Foundation Introduction –.Net foundations –Communication Protocols –SOA tenets WCF –Basics –Contracts.
Windows Communication Foundation and Web Services.
Copyright © 2007 CA. All trademarks, trade names, services marks and logos referenced herein belong to their respective companies. 5C The Plex SOA Strategy.
Darryl Burling Developer Evangelist Microsoft The age of connected applications Whats new in VS2008 WCF Background: WS*,.Net 3.0 and WCF ABC’s & improvments.
The Microsoft Technical Roadshow 2006 Windows Communication Foundation Mike Taulty Developer & Platform Group Microsoft Ltd
1 Web Services Visual C# 2008 Step by Step Chapter 30.
Module 13: WCF Receive Adapters. Overview Lesson 1: Introduction to WCF Receive Adapters Lesson 2: Configuring a WCF Receive Adapter Lesson 3: Using the.
Getting Started with Windows Communication Foundation 4.5 Ed Jones, MCT, MCPD, MCTS Consultant RBA Inc.
Getting Started with WCF Windows Communication Foundation 4.0 Development Chapter 1.
Introduction SOAP History Technical Architecture SOAP in Industry Summary References.
Copyright ©2004 Virtusa Corporation | CONFIDENTIAL Introduction to Windows Communication Foundation Ruwan Wijesinghe.
[Title of the course] WCF
Agenda What Is the Windows Communication Foundation? How Does It Work? How Do I Use and Deploy It? Bindings Addresses Contracts How to host WCF services.
SOA Visão Geral das Funcionalidades de Descoberta e Roteamento de Serviços em WCF 4.
Module 14: WCF Send Adapters. Overview Lesson 1: Introduction to WCF Send Adapters Lesson 2: Consuming a Web Service Lesson 3: Consuming Services from.
1 Windows Communication Foundation: Integrating COM+ and MSMQ Applications Andy Milligan COM305 Program Manager Microsoft Corporation.
Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#:
An program As a simple example of socket programming we can implement a program that sends to a remote site As a simple example of socket.
Web Services & WCF ~ Ankit. Web services A web service is a collection of protocols and standards used for exchanging data between applications or systems.
1 HKU CSIS DB Seminar: HKU CSIS DB Seminar: Web Services Oriented Data Processing and Integration Speaker: Eric Lo.
Presentation: Other Object Oriented Middlewares. Outline Web services Java RMI.NET Remoting WCF For each technology Compare: heterogenity (platform, OS,
CSCI 6962: Server-side Design and Programming Web Services.
James Holladay, Mario Sweeney, Vu Tran. Web Services Presentation Web Services Theory James Holladay Tools – Visual Studio Vu Tran Tools – Net Beans Mario.
1 UCN TB /IT 2011 Architecture Bindings –http –tcp –Msmq Serialization part 1 –With [DataContract] Running the services –In your own program –As a webservice.
Lecture 15 Introduction to Web Services Web Service Applications.
Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#:
Intro to WCF From the beginning and uses Steve AppRochester.
CS795/895: Introduction. Topics Distributed Systems –Availability –Performance –Web Services Security –Authentication –Authorization –Confidentiality.
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
Random Logic l Forum.NET l Web Services Enhancements for Microsoft.NET (WSE) Forum.NET ● October 4th, 2006.
Mahesh Krishnan, Senior Consultant, Readify Slide 1.
Telerik Software Academy Web Services & Cloud.
Getting Started with OPC.NET OPC.NET Software Client Interface Client Base Server Base OPC Wrapper OPC COM Server Server Interface WCF Alternate.
Kemal Baykal Rasim Ismayilov
Windows Communication Foundation David Anderson Independent Software Developer DCOM Productions.
Presentation 24: Windows Communication Foundation Introduced Objektorienteret Netværkskommunikation.
Agenda What Is the Windows Communication Foundation? How Does It Work? How Do I Use and Deploy It? Bindings Addresses Contracts How to host WCF services.
.NET Mobile Application Development XML Web Services.
Dhananjay Kumar MVP-Connected System 1. WCF  Agenda What is WCF ? Why WCF? Address, Binding, Contract End Points Hosting Message Patterns Programming.
The SOAP Story Martin Parry Developer & Platform Group Microsoft Ltd
1 Nordjyllands Erhvervakademi Net Remoting Architecture Marshalling –Marshalling By Reference(MBR) –Marshalling By Value(MBV) Activation by MBR.
In this session, you will learn to: Understand managed code Create managed database objects Define the Hypertext Transfer Protocol endpoints Implement.
OE-NIK HP Advanced Programming WCF WCF SOAP service, host, client Exception handling (NOT required)
Windows Communication Foundation Stipe Ivan Latković.
Nati Dobkin
O VERVIEW OF SOA AND WCF Jinaldesai.net – My Thouths And Learnings.
Windows Communication Foundation and Web Services
Windows Communication Foundation
Segments Introduction: slides 2–7 10 minutes
Windows Communication Foundation
Windows Communication Foundation
Window Communication Foundation
WCF.
Windows Communication Foundation
Windows Communication Foundation (WCF)
Distribution of functionality Webservice using WCF
Windows Communication Foundation and Web Services
אפליקציות אסינכרוניות ל-Windows 10
Windows Communication Foundation (WCF)
Creating a Distributed System with Remote Procedure Calls and Web Services Ch.5 B.Ramamurthy 2/17/2019 B.Ramamurthy.
Distributed System using Web Services
Distributed Applications on Windows Vista
The SOAP Story Martin Parry Developer & Platform Group Microsoft Ltd
Presentation transcript:

1 UCN 2012 Why use distributed (client / server) applications? To connect tiers within the same application... –client & server is both.NET assemblies Example: –A typical business app has Business and Data Access tiers –GUI calls into the business tier to get data, calculation & validation –Business tier makes calls to the data tier for writing / reading data DB DTBT Client (.NET) Server (.NET) Business Tier Data Access Tier

2 UCN 2012 Distributed app seen from the client and the server The client sees the server as an assembly.DLL –sets a reference to a object as normally The server makes.DLL available in one of two ways: 1.Runs as a service on the server, that responds on remote calls 2.Runs in the web server & trigger remote calls via URL –advances? #1 can use proprietary protocols & formats (more efficient) #2 is firewall-friendly, easy use of Windows security Client.exe.DLL Server

3 UCN 2012 Windows Communication Foundation Introduction –.Net foundations –Communication Protocols –SOA tenets (principles) WCF –Basics –Contracts –Bindings Build a WCF application –Build the service –Build the client –Host the service

4 UCN 2012.NET At The Core

5 UCN 2012 Distributed applications Many protocols and api’s for communication Web services MSMQ COM+ DCOM.NET Remoting Sockets CORBA P2P RMI

6 UCN 2012 WCF WCF provides a single extendable programming object model that can be used to interact with number of distributed technologies It makes it possible to offer multiple ways of communications, e.g. Web Services or.Net Remoting It is possible to extend the application with a new protocol without adding or refactoring code. It is done in the config file WCF is based on the design principles of SOA - Service-Oriented Architecture Supports strongly typed (.Net remoting) and loosely typed messages (XML) Supports multiple web service specs (WS*) e.g. SOAP and JSON Fully integrated security models (both windows models and independent models)

7 UCN 2012 Service-Oriented Architecture Many definitions exists. The simple definition: SOA is a way to design distributed systems where several autonomous services works in conjunction by passing messages across boundaries using interfaces WCF is based on 4 tenets of SOA: 1.Boundaries are explicit 2.Services are autonomous 3.Services communicates via contract, not implementation 4.Service compatibility is based on policy

8 UCN 2012 The ABC of WCF Three things are needed to build a WCF application: A.Address The location of the service. Normally stored in the config file B.Binding How to bind to the service. Should it be xml, binary etc. C.Contract Normally implemented as an interface in c#. But it is possible to add [ServiceContract] attributes to a normal class. Note: You don’t have to do it in the order of A, B and C. Actually in most cases you do it the opposite order Together ABC forms an endpoint.

9 UCN 2012 Contract Make an interface as usual. The interface methods will be the operations of the service. Use [ServiceContract] to define the interface as a (uhm..) service contract. Use [OperationContract] to define the method as an operation Let’s look at the WCFHelloWorld.WCFHelloWorld

10 UCN 2012 Contract Contract: Uses and references the backend: Implementing the service acting as a proxy for the backend:

11 UCN 2012 Binding The binding specifies how to use the service There may be specified more than one binding, meaning that there may be more than one way to access the service. The binding can specify: –The contracts implemented by the service –The transport layer (http, tcp, named pipes, msmq) –The channel for the transport (request-reply, one-way, duplex) –The encoding method (xml, binary, etc) –If a WS: Any supported web service protocols (WS-Transaction, WS-Security etc.) Don't confuse the terms tcp and http with OSI. Tcp and http are on different layers in OSI, and as you know http is on top of tcp

12 UCN 2012 Binding – App.config in the WcfService Project Binding and Contract (The “mex” endpoint is used by VS or other EDI)

13 UCN 2012 Binding – app.config in the Client Project Binding and Contract

14 UCN 2012 Exercises Exercise 1 (from GettingStartedWCF.pdf):GettingStartedWCF.pdf 1.HelloWorld 2.Add another client: Create a WinForm application that says ´”Hello World” using the same WCF service. Go through the same steps as when the console application was created. 3.Make your own distributed application: Make a back-end (Calculator) with methods for adding, subtracting and multiplying two numbers in same way as the HelloServer. Add a WCF service that uses the back- end. And finally, add a client.

15 UCN 2012 Http Binding – Open to the world The binding can be specified in the code by declaring an object, or (the easiest way) in the config file (using xml) Use http if the service should be reached by non.Net platforms or through Nat’s and firewalls There are by default 4 types of http binding: Element or the class BasicHttpBinding Basic web service functionality based on http and xml. Element, class WSHttpBinding Like BasicHttpBinding, but with support for transactions and reliable messaging Element, class WSDualHttpBinding Like WSHttpBinding, but makes possible for the service and the client to send message back and forth. Element, WSFederationHttpBinding Extended security. Supports ws-federation.

16 UCN 2012 Tcp binding – In-house Use tcp binding in-house on.Net based platforms Based on binary streams. Less bytes are transferred and no need for parsing Element, NetTcpBinding A secure and optimized method. Element, NetNamedPipeBinding Used for communication between applications on the same machine. Element, NetPeerTcpBinding Used for peer-to-peer, NetMsmqBinding Uses messages for cross-machine.Net platform communication, MsmqIntegrationBinding Used for communication with COM and native C++

17 UCN 2012 Which binding methods should I know for a start? BasicHttpBinding (or wsHttpBinding) NetTcpBinding

18 UCN 2012 The EightBall example The steps 1.Define the contract == define the interface and add contract attributes 2.Implement the service class (that implements the interface) 3.Do the ABC in the App.config file (on the server) 4.Implement the server 5.Implement the client –Generate proxy –Use the service Recommended: In VS2010 start by using the WCF Service project template

19 UCN 2012 Step 1: Define the contract Just make an interface as usual, and add the attributes [ ServiceContract(Namespace="noea.dk")] public interface IEightBall { [OperationContract] string ObtainAnswerToQuestion(string userQuestion); }

20 UCN 2012 Step 2: Implement the service Just a class public class MagicEightBallService:IEightBall { public MagicEightBallService() { Console.WriteLine("The 8-ball awaits your question...."); } public string ObtainAnswerToQuestion(string userQuestion) { string[] answers = { "Future uncertain", "Yes", "No", "Hazy", "Ask again later", "Definitely" }; Random r = new Random(); return string.Format("{0}? {1}",userQuestion,answers[r.Next(answers.Length)]); }

21 UCN 2012 The.config file Configuration files are widely used in.Net A configuration file provides an easy way of changing different kind of setting. For example: –Database connection strings –Authorization settings –Remoting settings –Application specific properties In Visual Studio: Add a new item using the “Application Configuration File” template Leave the name as app.config. It will be renamed to.config. E.g.: MyProgram.exe.config

22 UCN 2012 Step 3: The config file (basic) <endpoint address="" binding="basicHttpBinding" contract="MagicEightBallServiceLib.IEightBall"/>

23 UCN 2012 Step 3: The config file (enable wsdl) ………… <service name="MagicEightBallServiceLib.MagicEightBallService" behaviorConfiguration="EightBallServiceMEXBehavior"> <endpoint address="" binding="basicHttpBinding" contract="MagicEightBallServiceLib.IEightBall"/> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> ………….. ……………….

24 UCN 2012 Step 4: The Server using System; using System.ServiceModel; using MagicEightBallServiceLib; namespace MagicEightBallServiceHost { class Program { static void Main(string[] args) { Console.WriteLine("Console Based WCF Host"); using (ServiceHost serviceHost = new ServiceHost(typeof(MagicEightBallService))) { serviceHost.Open(); Console.WriteLine("The service is ready."); Console.WriteLine("Press the Enter key to terminate service."); Console.ReadLine(); }

25 UCN 2012 The using statement (not the using declaration) The using statement ensures that the object is disposed, when it goes out of scope. Is similar to this code: { ServiceHost serviceHost = new ServiceHost(typeof(MagicEightBallService))) try { serviceHost.Open(); ….. } finally { if (serviceHost != null) ((IDisposable) serviceHost).Dispose(); }

26 UCN 2012 The Client Basically create the proxy class It can be done in VisualStudio by adding a Service Reference If you have the server and the client in the same solution, you have start the server from outside of VS before adding the reference Another way is to use svcutil.exe from the command prompt This will create a config file and a cs file containing the proxy class

27 UCN 2012 Step 5: The Client Autogenerated config file <binding name="BasicHttpBinding_IEightBall" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> <endpoint address=" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IEightBall" contract="test.IEightBall" name="BasicHttpBinding_IEightBall" />

28 UCN 2012 Step 5: The Client Stripped config file <endpoint address=" binding="basicHttpBinding" contract="test.IEightBall" name="BasicHttpBinding_IEightBall" />

29 UCN 2012 Step 5: The Client The exe file using MagicEightBallClient.test; namespace MagicEightBallClient { class Program { static void Main(string[] args) { using (test.EightBallClient ball = new EightBallClient()) { Console.Write("Your question: "); string question = Console.ReadLine(); string answer = ball.ObtainAnswerToQuestion(question); Console.WriteLine("8-ball says: {0}",answer); } Console.ReadLine(); }

30 UCN 2012 Run the example The server must run in administrator mode on Vista and Windows 7 Either start Visual Studio or the server in administrator mode: right click-> run as administrator

31 UCN 2012 Exercises Exercise 2: –Change the EightBall server so it also supports.netTcp –Change the client (or make a new) to use the.netTcp