WCF WINDOWS COMMUNICATION FOUNDATION OVERVIEW OF WCF, MICROSOFTS UNIFIED COMMUNICATION FRAMEWORK FOR.NET APPLICATIONS

Similar documents
HexaCorp. White Paper. SOA with.net. Ser vice O rient ed Ar c hit ecture

ASMX

Introducing Windows Communication Foundation

ITS. Java WebService. ITS Data-Solutions Pvt Ltd BENEFITS OF ATTENDANCE:

Developing Java Web Services

JVA-561. Developing SOAP Web Services in Java

Java Web Services Training

WEB SERVICES. Revised 9/29/2015

Attacking WCF Web Services. AppSec DC. The OWASP Foundation. Brian Holyfield Gotham Digital Science

A standards-based approach to application integration

70-487: Developing Windows Azure and Web Services

Integration of Hotel Property Management Systems (HPMS) with Global Internet Reservation Systems

Introducing Windows Communication Foundation

Implementing a WCF Service in the Real World

Szolgáltatásorientált rendszerintegráció. WS-* standards

NUTECH COMPUTER TRAINING INSTITUTE 1682 E. GUDE DRIVE #102, ROCKVILLE, MD 20850

Web Services Development for IBM WebSphere Application Server V7.0. Version: Demo. Page <<1/10>>

New Features in Neuron ESB 2.6

Microsoft Dynamics CRM Event Pipeline

JAVA API FOR XML WEB SERVICES INTRODUCTION TO JAX-WS, THE JAVA API FOR XML BASED WEB SERVICES (SOAP, WSDL)

Contents. Overview 1 SENTINET

EAI OVERVIEW OF ENTERPRISE APPLICATION INTEGRATION CONCEPTS AND ARCHITECTURES. Enterprise Application Integration. Peter R. Egli INDIGOO.

.NET 3.0 vs. IBM WebSphere 6.1 Benchmark Results

Distribution and Integration Technologies

Developing Windows Azure and Web Services

Whats the difference between WCF and Web Services?

MICROSOFT EXAM QUESTIONS & ANSWERS MICROSOFT EXAM QUESTIONS & ANSWERS

Principles and Foundations of Web Services: An Holistic View (Technologies, Business Drivers, Models, Architectures and Standards)

rpafi/jl open source Apache Axis2 Web Services 2nd Edition using Apache Axis2 Deepal Jayasinghe Create secure, reliable, and easy-to-use web services

WCF Service Creation With C#

JBoss SOAP Web Services User Guide. Version: M5

This module provides an overview of service and cloud technologies using the Microsoft.NET Framework and the Windows Azure cloud.

Simplifying Processes Interoperability with a Service Oriented Architecture

Outline SOA. Properties of SOA. Service 2/19/2016. Definitions. Comparison of component technologies. Definitions Component technologies

Introduction to WebSphere Process Server and WebSphere Enterprise Service Bus

ActiveVOS Server Architecture. March 2009

Sentinet for BizTalk Server SENTINET

Sentinet for BizTalk Server SENTINET 3.1

Windows Azure Data Services (basics) 55093A; 3 Days

Service Oriented Architecture

Extended Web Services Standards

Software + Services Using WCF and WF

Copyright 2012, Oracle and/or its affiliates. All rights reserved.

Assessing the usefulness of the WS-I tools for interoperability testing

Evaluating.NET-Based Enterprise Service Bus Solutions

SOA, BPM, and Microsoft: A Pragmatic View

Getting started with API testing

Increasing IT flexibility with IBM WebSphere ESB software.

Service-Oriented Architectures

Contents Huntcliff, Suite 1350, Atlanta, Georgia, 30350, USA

Windows Communication Foundation

WCF and Windows Activation Service(WAS)

Microsoft Dynamics CRM2015 Fast Track for developers

Introduction to WCF 3.5 and Rest

Java Security Web Services Security (Overview) Lecture 9

Oracle Service Bus. User Guide 10g Release 3 Maintenance Pack 1 (10.3.1) June 2009

Course 20489B: Developing Microsoft SharePoint Server 2013 Advanced Solutions OVERVIEW

Developing Web Services Applications


Microsoft Dynamics CRM 2013/2015 Event Pipeline

CLOUD COMPUTING & WINDOWS AZURE

Creating Form Rendering ASP.NET Applications

Building and Using Web Services With JDeveloper 11g

MS 10978A Introduction to Azure for Developers

CT30A8902 Service Oriented Architecture Exercises

Developing Microsoft SharePoint Server 2013 Advanced Solutions

Using Web Services to exchange information via XML

Web Services Manageability Concepts (WS-Manageability)

Integrating SalesForce with SharePoint 2007 via the Business Data Catalog

fpafi/tl enterprise Microsoft Silverlight 5 and Windows Azure Enterprise Integration Silverlight Enterprise Applications on the Windows

Industrial Network Security and Connectivity. Tunneling Process Data Securely Through Firewalls. A Solution To OPC - DCOM Connectivity

Introduction into Web Services (WS)

IBM SPSS Collaboration and Deployment Services Version 6 Release 0. Single Sign-On Services Developer's Guide

Grid Computing. Web Services. Explanation (2) Explanation. Grid Computing Fall 2006 Paul A. Farrell 9/12/2006

Programming in C# with Microsoft Visual Studio 2010

Part 2: The Neuron ESB

GETTING STARTED GUIDE

VALLIAMMAI ENGINEERING COLLEGE SRM NAGAR, KATTANKULATHUR DEPARTMENT OF COMPUTER APPLICATIONS SUBJECT : MC7502 SERVICE ORIENTED ARCHITECTURE

Visual Basic. murach's TRAINING & REFERENCE

Web Services Development for IBM WebSphere App Server V7.0 Exam.

VB.NET - WEB PROGRAMMING

Replacements TECHNICAL REFERENCE. DTCCSOLUTIONS Dec Copyright 2009 Depository Trust Clearing Corporation. All Rights Reserved.

Neuron ESB 3.5 introduces Long Running Workflow capabilities!

"An infrastructure that a company uses for integrating services in the application landscape."

Developing Microsoft SharePoint Server 2013 Advanced Solutions

Web Services Technologies

MD Link Integration MDI Solutions Limited

Building SOA Applications with JAX-WS, JAX- RS, JAXB, and Ajax

GRA Reliable Secure Web Services Service Interaction Profile Version 1.2 Table of Contents

SCA-based Enterprise Service Bus WebSphere ESB

Sentinet for Windows Azure SENTINET

MOC DEVELOPING WINDOWS AZURE AND WEB SERVICES

Introduction to Service Oriented Architectures (SOA)

24 BETTER SOFTWARE MARCH

Mikias Mulugeta. Distributed Database Integration with Web Services

Introduction to UDDI: Important Features and Functional Concepts

Programmabilty. Programmability in Microsoft Dynamics AX Microsoft Dynamics AX White Paper

StreamServe Persuasion SP4 Service Broker

Enhancing A Software Testing Tool to Validate the Web Services

PROGRESS Portal Access Whitepaper

Transcription:

WCF WINDOWS COMMUNICATION WCF Windows Communication Foundation FOUNDATION OVERVIEW OF WCF, MICROSOFTS UNIFIED COMMUNICATION FRAMEWORK FOR.NET APPLICATIONS Peter R. Egli INDIGOO.COM 1/24

Contents 1. What is WCF? 2. WCF s ABC 3. WCF model 4. The 4 layers of the WCF architecture 5. WCF programming model 6. WCF address (the 'A' in 'ABC') 7. WCF binding (the 'B' in 'ABC') 8. WCF contract (the 'C' in 'ABC') 9. WCF service hosting 10. Steps for creating and running a WCF service 11. WCF configuration versus programming 12. WCF and SOAP messages 2/24

1. What is WCF (1/3)? WCF is a unified communication framework for distributed applications. WCF defines a common programming model and unified API for clients and services to send messages between each other. WCF is the current and future standard for distributed.net applications. Key characteristics of WCF: Service-oriented programming model (SOA): Services are offered on an endpoint. WCF completely separates service hosting, endpoints and services. Interoperability with non-wcf web services due to use of SOAP messages: WCF implements many of the WS-* standards. See http://msdn.microsoft.com/en-us/library/ms734776.aspx. Extensibility: WCF client / server can be configured to interoperate with REST, ATOM-feeds, plain XML or JSON messages (extensions for interfacing to any message-based service). 3/24

1. What is WCF (2/3)? It provides a unified API to use various types of communication from an application. WCF sits on top of the.net Framework. WCF provides a unified API for various communication models. WCF client (.Net program) WCF Message-oriented communication WCF service (.Net program) WCF.Net FW MSMQ DCOM TCP/IP WS HTTP.Net FW MSMQ DCOM WS TCP/IP HTTP WCF versus web services: WCF is service-oriented. By separating the service interface (contract) from the transport protocol and message encoding, a (logical) service can be reused in different scenarios. A developer is forced to specify a service interface on a logical level and then define how the service may be used (transport protocol, message encoding). These characteristics nicely map to the web service paradigm where a WSDL-file defines the what (service interface), the how (transport, message encoding) and the where (endpoint address). But: WCF also supports distributed applications that are not web service based. 4/24

1. What is WCF (3/3)? WCF is a generic communication framework. WCF supports WS and other means of communication. WCF supports different (message-based) communication protocols. Possible scenarios with WCF: Client WCF Server WCF Client and server communice asynchronously over an MSMQ (message queueing) infrastructure. MSMQ MSMQ MSMQ Client Web service WCF HTTP WCF HTTP Web service client and service use WCF for communication. WCF provides interoperability with non-wcf web service clients / services. Client WCF Pipe Service proc. WCF Pipe Client and server use named pipes for communication. 5/24

2. WCF s ABC The core concept of WCF is a service that is provided on an endpoint and accessible over the network through a transport protocol. Thus a WCF service is defined by ABC: A = Address: Where is the service available (the endpoint's URI in case of a web service). B = Binding: How can the service be accessed (what transport protocol is used). C = Contract: What does the service interface look like (operations, data-types). The mapping of the ABCs to WSDL: WCF term Question WSDL element A (Address) Where <service> including element <endpoint> B (Binding) How <binding> C (Contract) What <types> <interface> 6/24

3. WCF model (1/4) WCF defines a (consistent) service model with entities and relationships. Message uses Channel Channel has WCF client Endpoint Application has WCF service 1 1 has has * * 1 has * Communication stack Security protocol * Message encoding Endpoint 1 has Text/ XML hosted in has MTOM Binary Instancing model Appl. endpoint Infrastructure endpoint has Host Single Session Per call implements has Self-hosted Service host corresponds to Provides service metadata Message exchange pattern Message contract Service contract Address as URI contains WSDL Operation contract uses Data contract ABC elements (blue) are described by a WSDL file. Channel Transport protocol Binding elements HTTP TCP MSMQ Request reply Oneway Duplex 7/24

3. WCF model (2/4) Application: An application has a WCF client and / or WCF service. WCF client: Component with a WCF endpoint for communicating with a WCF service through messages. WCF service: Counterpart to WCF client. Runs in its own process (self-hosted) or in a specific service hosting process (IIS, Windows Activation Service, Windows Service). Endpoint: WCF client and service use an endpoint to connect to each other. Application endpoint: Endpoint on which an application service is exposed / offered. Infrastructure endpoint: Part of WCF system to offer metadata of an application service. Message: Unit of data exchange between WCF client and service. WCF is strictly message-based. Address: Physical address comprising hostname, port number and service name (=URI). The application service is accessible under such an address. Example.: http://localhost:8000/hsz-twsmw/datetimeservice 8/24

3. WCF model (3/4) Service contract: Set of operations which define the application service. The service contract is implemented by an interface in a.net language (e.g. C# interface). Operation contract: Defines the signature (parameters and return type) of an individual operation of a service. Message contract (SOAP message layout): Describes the format of a message (which information elements should go into the header, which should go into the body, level of security to be applied to message etc.). Instancing model: Defines how the service is instantiated: Singleton, Session, Single-Call. Binding (element): Defines how an endpoint communicates with its peer endpoint. Binding elements define individual aspects of the communication, basically the transport protocol (raw TCP, HTTP), message encoding (text, binary) and the security. Channel: Concrete implementation of a binding element (binding element = configuration, channel = implementation). 9/24

3. WCF model (4/4) Transport protocol (transport binding): Defines the protocol used to transfer messages over the wire (wire protocol). A common transport protocol is HTTP (HTTP over TCP). Message encoding (binding element): Defines the formatting of messages before they are sent over the wire (using the transport protocol). Common message encodings are text/xml (SOAP) or MTOM (Message Transmission Optimized Mechanism) for efficient transfer of binary data. Security protocol (security binding): Defines what security functions (authentication, encryption) are applied to messages. Message exchange pattern: Defines how messages are exchanged (request-reply, one-way, duplex). Communication stack: Comprises different binding elements, at a minimum a transport binding element and message encoding binding element. Host: Runtime environment for a service. Either self-hosted (specific process for service) or a general hosting process, e.g. IIS, WAS or Windows service. 10/24

4. The 4 layers of the WCF architecture Contracts Data Contract Service Runtime Message Contract Application Service Contract Policy and Binding Contracts define the service (as XSD): Data contract Definition of complex types (structures, classes, generics). Service contract (C) Definition of operation signatures. Message contract (C) Layout of (SOAP) messages. Policies and binding (B) Definition of transport protocol (TCP, HTTP) and message encoding (text, binary); security functions used (if any). Throttling Behavior Transaction Behavior Error Behavior Dispatch Behavior Metadata Behavior Instance Behavior Concurrency Behavior Message Inspection Parameter Filtering Service runtime contains runtime behavior (functions of service host): Examples: Error behavior, throttling message reception, delivery of service metadata to the outside world. Messaging WS Security Channel HTTP Channel TCP Channel WS Reliable Messaging Channel Transaction Flow Channel Encoders: Binary/MTOM /Text/XML NamedPipe Channel MSMQ Channel Messaging layer with channels (channel = implementation of binding element): - Security (authentication & encryption) & reliability (reliable messaging) channels. - Message encoding channels (text, binary, MTOT, XML). - Transport channels (TCP, HTTP). All used channels comprise the channel stack. Activation and Hosting Windows Activation Service.exe (selfhosting) Windows Services COM+ Channels, service runtime behaviors and service itself (modules implementing the contracts) are run in a host process. Services can be: a. Self-hosted (run in their own process). b. Hosted by an external agent (WAS, IIS, Windows services). 11/24

5. WCF programming model (classes and interfaces) The ABC elements of WCF are offered as specific class libraries. WCF term A (Address) B (Binding) C (Contract) Corresponding class library (namespace) System.Uri System.ServiceModel E.g. BasicHttpBinding (SOAP, non-secure, interoperable, non-duplex) WebHttpBinding (REST-style binding, i.e. non-soap) Interfaces / classes annotated with System.ServiceModel attributes: [OperationContract] [ServiceContract] [MessageContract] Data contract (definitions of types used in operation contracts): [DataContract] (System.Runtime.Serialization) E (Endpoint) System.ServiceModel.ServiceEndpoint 12/24

6. WCF address (the 'A' in 'ABC') The WCF address defines where a web service (endpoint) is accessible. WCF models an address as an endpoint reference (EPR) as per the WS-Addressing standard. WS-Addressing EPR schema: <wsa:endpointreference> <wsa:address>xs:anyuri</wsa:address> URI <wsa:referenceproperties>... </wsa:referenceproperties>? Properties to identify the endpoint <wsa:referenceparameters>... </wsa:referenceparameters>? Parameters associated with an endpoint <wsa:porttype>xs:qname</wsa:porttype>? Endpoint type (WSDL 1.0 porttype, WSDL 2.0 interface) <wsa:servicename PortName="xs:NCName"?>xs:QName</wsa:ServiceName>? Link to WSDL service element containing the endpoint descr. <wsp:policy>... </wsp:policy>* Security settings of endpoint </wsa:endpointreference> WS-addressing EPR see http://www.w3.org/submission/ws-addressing/#_toc77464317 Example endpoint address URI: http://localhost:8000/hsz-twsmw/datetimeservice Scheme / protocol Machine address (IP or DNS) Port # Path under which the service is available Endpoint address class System.ServiceModel.EndpointAddress: EndpointAddress.Uri URI EndpointAddress.Headers Reference properties and parameters EndpointAddress.Identity Security settings 13/24

7. WCF binding (the 'B' in 'ABC') (1/2) The binding defines how a web service endpoint is accessed. A binding contains the following elements: 1. Transport protocol: Underlying transport protocol to use when interacting with the web service. Examples: TCP, HTTP, MSMQ. 2. Message encoding: Definition of the message encoding. Examples: Text/XML (SOAP), binary, MTOM (Message Transfer Optimized Mechanism). 3. Security / reliability settings: Message security settings (e.g. encryption and authentication of message). Transport security (e.g. encryption of transport connection). Encoder + Security Encoding and securing of application messages. Transport connection and protocol Encoder + Security Encoding and securing of application messages. 14/24

7. WCF binding (the 'B' in 'ABC') (2/2) WCF provides the following bindings: Binding Interoperability Security Session Transactions Duplex Encoding BasicHttpBinding WS-I Basic Profile N, T, M, m N N No Text, MTOM WSHttpBinding WS-* standards T, M, m N, RS, SS N, Yes No Text, MTOM WSDualHttpBinding WS-* standards M, m RS, SS N, Yes Yes Text, MTOM WSFederationHttpBinding WS-Federation N, M, m RS, SS N, Yes No Text, MTOM NetTcpBinding.NET T, M, m, N TS, RS, SS N, Yes Yes Binary NetNamedPipeBinding.NET T, N N, TS N, Yes Yes Binary NetMsmqBinding.NET (WCF) M, T, N N, TS N, Yes No Binary NetPeerTcpBinding.NET T N N Yes N/A MsmqIntegrationBinding MSMQ T N N, Yes No MSMQ BasicHttpContextBinding WS-I Basic Profile N, T, M, m N N No Text, MTOM NetTcpContextBinding.NET N, T, M, m T, RS, SS N, Yes Yes Binary WSHttpContextBinding WS-* standards T, M, m N, RS, SS N, Yes No Text, MTOM WebHttpBinding HTTP (REST) N N N No POX More details on WCF bindings see http://msdn.microsoft.com/en-us/library/ms730879.aspx. Key: N: None T: Transport M: Message m: mixed RS: SS: TS: Reliable Session (WS-ReliableMessaging) Security Session Transport Session POX: Plain Old XML 15/24

8. WCF contract (the 'C' in 'ABC') WCF interfaces are called contracts (both client and server must comply with the contract). Contracts describe operations, data structures and messages. A service contract defines: a. Grouping of operations in a service.net attribute [ServiceContract] b. Signature of operations.net attribute [OperationContract] c. Data types of operations.net attribute [DataContract] From contract to code (and back): The utility SvcUtil.exe may be used to map between abstract and interoperable service definitions (WSDL documents) and programmatic definitions of interfaces (C# code). SvcUtil.exe either retrieves the service definition from a WSDL file on disk using the DISCO protocol (Microsoft proprietary WS discovery protocol) or directly from a running service instance through the standard WS-MetaDataExchange protocol. WSDL / XSD SvcUtil.exe.Net C# code Exportable contract description Programmatic definition of contract 16/24

9. WCF service hosting A service host is the process that runs (executes) the service(s). WCF provides different possibilities to host a service. A. Self-hosted service: The service runs in an application process that the developer created. The lifecycle (when is service opened and closed) is controlled by the service itself. B. Standard Windows hosting process:.net and Windows offer system processes that are designed to host services. a. IIS (Internet Information Services): Only HTTP transport supported (IIS is a web server). b. WAS (Windows Activation Services): New process activation framework on which IIS 7.0 is based. Supports HTTP, TCP, and pipe transports. c. Windows services: Standard Windows execution with security etc. Lifecycle of service controlled by service startup configuration. More information and a comparison of WCF hosting options see http://msdn.microsoft.com/enus/library/ms730158.aspx. 17/24

10. Steps for creating and running a WCF service (1/4) The following steps outline how to create a web service in Visual Studio 2010. 1. Visual Studio 2010 project selection (1/2): The hosting environment of a web service defines the project template to be used. a. Visual C# / WCF / WCF Service Library project: Output: Service DLL (Dynamic Link Library). To be run in WAS. Files: IService1.cs with [ServiceContract] attributes (service interface = contract). Service1.cs (service implementation of interface). App.config (configuration file with transport binding and other settings). b. Visual C# / WCF / WCF Service Application project: Output: Service DLL. To be run in IIS. Files: IService1.cs with [ServiceContract] attributes. Service1.cs (service implementation). Web.config (configuration file with HTTP-transport binding and other settings). 18/24

10. Steps for creating and running a WCF service (2/4) The following steps outline how to create a web service in Visual Studio 2010. 1. Visual Studio 2010 project selection (2/2): c. Self-hosted: Standard C# application project. d. Managed Windows service (formerly called NT service): Windows service project. Implementing class has to inherit from ServiceBase (base class for Windows service) as well as from a WCF service interface. 19/24

10. Steps for creating and running a WCF service (3/4) 2. Interface definition (service contract as C# interface or C# class): Define the interface of the web service with a.net interface. Example interface contract definition in C# (containing operation contracts): [ServiceContract(Namespace = "http://indigoo.wsmw")] public interface IMyInterface { [OperationContract] string MyFunction(); [OperationContract] int MyOtherFunction(); } 3. Service contract implementation (C# class implementing the interface): Create.Net class that implements the web service interface. public class MyService : IMyInterface { public string MyFunction() {...}... } 20/24

10. Steps for creating and running a WCF service (4/4) 4. Deploy and run the service: The final step is to deploy the service assembly (DLL) into the hosting environment or to start it in case of self-hosting. For self-hosting services, the following code needs to be added to the service (definition of endpoint with address and binding): selfhost.addserviceendpoint(typeof(myservice), new BasicHttpBinding(), "MyService"); Finally the service can be started in the WCF self-hosting environment as follows: selfhost.open(); 21/24

11. WCF configuration versus programming (1/2) WCF client and service can be defined by configuration (XML file, declarative) or programmatically (.Net classes). Good practice: For improved reusability of web services in different environments, contract ('C') and address ('A') as well as transport binding ('B') should be separated. Define interface and implementation programmatically (C#) without transport and message encodings. Definition of transport binding, address and message encoding in configuration file. Declarative service configuration: Major sections of a service configuration (App.config or Web.config)) file are: <system.servicemodel> <services> <service> <endpoint/> </service> </services> <bindings> <!-- Specify one or more of the system-provided binding elements, for example, <basichttpbinding> --> <!-- Alternatively, <custombinding> elements. --> <binding> <!-- For example, a <BasicHttpBinding> element. --></binding> </bindings> <behaviors> <!-- One or more of the system-provided or custom behavior elements. --> <behavior> <!-- For example, a <throttling> element. --> </behavior> </behaviors> </system.servicemodel> 22/24

11. WCF configuration versus programming (2/2) Graphical configuration of service with SvcConfigEditor.exe: The service can be configured graphically with the utility SvcConfigEditor.exe (path 'Microsoft SDKs\Windows\v7.0A\Bin\SvcConfigEditor.exe). SvcConfigEditor.exe can also be launched through the App.config / Web.config files' context menu: 23/24

12. WCF and SOAP messages Usually WCF hides the mapping of operations (operation contracts, data contracts) to SOAP messages (WCF bindings that use SOAP messages automatically map operations into SOAP messages). If necessary, WCF MessageContracts provide complete control over the structure of the exchanged SOAP messages (similar concept to JAX-WS @WebServiceProvider annotations). MessageContracts define a class that can be used as argument type in operations. In MessageContracts, the class members can be mapped to the SOAP header or body as follows: namespace WSMW_WCF { [ServiceContract] interface IHelloWorld { [OperationContract] HelloResponseMessage SayHello(String hellomsg); } [MessageContract] public class HelloResponseMessage { private string localresponse = "..."; private string extra = "..."; [MessageBodyMember] public string Response { get { return localresponse; } set { localresponse = value; } } [MessageHeader] public string ExtraValues { get { return extra; } set { this.extra = value; } } } } 24/24