1. Trang chủ
  2. » Công Nghệ Thông Tin

windows vista for developers delivery guide phần 6 pdf

21 216 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 21
Dung lượng 1,27 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

WCF can be deployed in one of two forms, either through Windows Activation Service WAS, which is very similar to how you deploy ASP.NET Web Services ASMX in IIS, or directly in any inter

Trang 1

Choosing and Configuring Bindings

There are two steps when using bindings:

1 Choose or define a binding The easiest method is to choose one of the predefined

bindings included with WCF and use it with its default settings

2 Create an endpoint that uses the selected or defined binding

Choosing Bindings

Bindings are objects used to specify the communication details required to connect to the

endpoint of a WCF service Each endpoint in a WCF service requires a binding to be

well-specified

The information in a binding can be complex, and some settings may not be compatible

with others For this reason, WCF includes a set of predefined bindings These bindings

(also known as standard bindings) are designed to cover most application requirements

If none of the standard bindings has the right combination of features that a service

application requires, you can create your own custom binding

Trang 2

The following classes represent some examples of predefined bindings:

BasicHttpBinding An HTTP protocol binding suitable for connecting to Web services that

conforms to the WS-I Basic Profile specification (for example, based services)

ASMX-WSHttpBinding An interoperable binding suitable for connecting to endpoints that

conform to the WS-* protocols

NetNamedPipeBinding Uses the NET Framework to connect to other WCF endpoints on the

or custom binding In general, using code gives you complete control over the definition

of a binding at design time Using configuration, on the other hand, allows a system administrator or the user of a WCF service or client to change the parameters of a binding without having to recompile the service application This flexibility is often desirable because there is no way to predict specific machine requirements on which a WCF application is to be deployed Keeping the binding (and the addressing) information out

of the code allows them to change without requiring recompilation/redeployment of the application

You can use the Service Metadata Utility Tool (Svcutil.exe) with the /config switch to quickly create configuration files

In the configuration file, use the section bounded by the System.ServiceModel element

to configure both a service type that has one or more endpoints and settings for a service Each endpoint can then be configured with an address, a contract, and a binding

Trang 3

An example of the configuration file is:

The WinFX Software Development Kit (SDK) includes a tool named

SvcConfigEditor, which provides a graphical interface for working with the various

<system.serviceModel> settings

Trang 4

Demonstration 2: Building a WCF Service

In this demonstration, you will see how you can build a WCF Service by using Visual

Studio 2005

Key Points

The key points of this demonstration are:

• The first step in creating a WCF service is to define the contract

• The second step is to implement the contract

Trang 5

Deploying the WCF Service

After building the service, the next step is to deploy the code to provide the service WCF

can be deployed in one of two forms, either through Windows Activation Service (WAS),

which is very similar to how you deploy ASP.NET Web Services (ASMX) in IIS, or

directly in any internal application classes that need to make use of the service WCF

supports the following deployment options:

• Self-Hosting in a Managed Application This is the most flexible option because it

requires the least infrastructure to deploy You can use ClickOnce or a conventional

MSI Windows installer to deploy the application

• Managed Windows Services These services are managed through the Services

snap-in added to the Microsoft Management Console (MMC) and can be configured to

start up automatically when the system boots up To deploy the WCF service as a

Windows service:

• The service code must include an installer class and a service implementation

class

• The installer class must inherit from iInstaller and allow the program to be

installed as an NT service by the Installutil tool

Trang 6

• The service class must inherit from ServiceBase and implements the OnStart and OnStop methods

• After the service is built, it needs to be installed with the Installutil utility just like any other NT Service

• Internet Information Services (IIS) A WCF service that runs in the Internet

Information Services (IIS) environment takes full advantage of IIS features, such as controlling when the service runs and disposal of resources To deploy the service

to IIS:

• Create a new folder for the code files and allow ASP.NET to access the contents

• Use the IIS management tool to create a new virtual directory

• Copy your code including the service file with the svc file extension in the new directory

• Create the Web.config file that contains the endpoint information At run time, the WCF infrastructure uses this information to construct an endpoint that client applications can communicate with

• Windows Activation Service (WAS) WAS is the new process activation mechanism for Microsoft Windows Server code-named Longhorn operating system It retains the

familiar IIS 6.0 process model (application pools and message-based process

activation) and hosting features (such as rapid failure protection, health monitoring, and recycling), but it removes the dependency on HTTP from the activation

architecture

Trang 7

Demonstration 3: Deploying a WCF Service on IIS

In this demonstration, you will see how you can deploy a WCF Service on IIS

Key Points

The key points of this demonstration are:

• The first step in deploying the WCF service is to add the Web application to IIS

• The Service.svc and the Web.config file describe how the application will be hosted

in IIS

• You can modify the Web.config file to enable metadata publishing

Trang 8

Consuming the WCF Service

After the service has been deployed, client applications can begin to use, or consume, the

service To consume the service, the client application must be a managed application

that uses a WCF client object to communicate with another application

To consume the service, the client application must use WCF client objects A WCF

client object is an object that represents a WCF service in a form that the client can use

locally to communicate with the remote service Objects of this kind (often called proxy

objects or proxies), represent an object that is physically located somewhere else and

enable local callers to make easy use of the actual remote object by interacting with the

proxy Client applications use WCF client objects to invoke the functionality of a service

There are two types of WCF client objects: objects that extend ClientBase and channel

objects returned from a call to the CreateChannel method Because channel objects

implement interfaces, they directly model the inputs and outputs of abstract services in

managed form and are implemented dynamically by the WCF client runtime

Trang 9

Demonstration 4: Writing a Client to Use the WCF Service

In this demonstration, you will see how to write a client to use the WCF Service

Key Points

The key points of this demonstration are:

• To write the client, add a reference to the System.ServiceModel assembly

• Use svcutil to generate the Windows Communication Foundation Client code

• Alter the code in the Program.cs file to use the class generated by the Service

Metadata Tool as a proxy

Trang 10

Securing the WCF Service

Security of a WCF service consists of two primary requirements: transfer security and

authorization

Transfer security includes:

• Authentication, which is the verification of identity, both of the service and the client

• Confidentiality, which is provided by the encryption of messages

• Integrity, which uses digital signing to detect tampering

Authorization is the control of access to resources, for example, allowing only privileged

users to read a file

WCF Security Modes

There are three modes of security that you can choose from:

• Transport mode There are several protocols used in WCF, and each can be used to

secure the transfer of messages Commonly used protocols include the Hypertext

Transfer Protocol (HTTP) and the Transmission Control Protocol (TCP) Each of

these protocols can secure message transfer by a mechanism particular to the protocol

For example, by selecting WSHttpBinding and setting its security mode to

Transport, you are selecting SSL over HTTP (HTTPS) as the security mechanism

Trang 11

• Message mode This mode provides security by including the security data as part of

every message XML and SOAP security headers provide every message with the credentials and other data needed to ensure integrity and confidentiality

• Transport with message credentials mode This mode combines the best of both

transport and message security With this mode, transport security is used to

efficiently ensure the confidentiality and integrity of every message At the same time, every message includes its credential data, which allows the message to be

authenticated

Trang 12

Demonstration 5: Securing the WCF Service by Using a Secure

Transport Protocol

In this demonstration, you will see how you can secure a WCF service by using SSL

Key Points

The key points of this demonstration are:

• By configuring a certificate for SSL on the Web server and configuring the WCF

client to use SSL, you can secure the network traffic between the Web server and

client

Trang 13

Developing Workflows by Using the Windows Workflow

Foundation

Introduction

Windows Workflow Foundation provides the programming model and the infrastructure

to create workflow applications Workflow applications complete a series of steps, often

emulating a real-world process To simplify the creation of workflow applications built

on the Windows Workflow Foundation, Microsoft provides the Visual Studio Extensions

for Windows Workflow Foundation

Objectives

After completing this section, you will be able to:

• Describe the Windows Workflow Foundation features and components

• List the workflow scenarios

• Describe the workflow authoring styles and modes

• Use Visual Studio Extensions for Windows Workflow Foundation

• Implement activities in workflows

• Implement conditions in workflows

Trang 14

Introduction to Programming Windows Workflow Foundation

Windows Workflow Foundation consists of the programming model, engine, and tools

for quickly building workflow-enabled applications for Windows Windows Workflow

Foundation consists of a namespace, an in-process workflow engine, and designers for

Visual Studio 2005

What are workflows?

A workflow is an application that performs a number of steps during its execution

Typically, these steps model a business process For example, a workflow may model the

submission, approval, and payment process for an invoice

Windows Workflow Foundation architecture

The Windows Workflow Foundation is made up of the following components:

• Activities Activities are the building blocks of a workflow You can add activities to

a workflow imperatively through code or declaratively using XAML (Extensible

Application Markup Language) You can create your own activities or use those

provided with WF Once all of the activities in a given flow path are finished running,

the workflow instance completes

Trang 15

• Workflow A workflow is a set of activities stored as a model that describe a

real-world process Work passes through the model from start to finish, and activities might be executed by people or by system functions A workflow provides a way of describing the order of execution and dependent relationships between pieces of short- or long-running work

• Custom activity libraries Windows Workflow Foundation provides the mechanisms

for you to create your own activities that can be stored in custom libraries This allows extensibility and reusability between workflows

• Runtime services Windows Workflow Foundation includes several runtime services

that can be plugged into the workflow runtime engine These services are divided into these categories:

• Base activity library and framework Windows Workflow Foundation contains a

library of standard activities The Windows Workflow Foundation namespace in

Microsoft NET Framework version 3.0 is called System.Workflow

• Host process An application that executes workflows and manages their lifetimes is referred to as a workflow host Workflows, activities, and the workflow runtime

engine are all hosted in a process with a host application

Trang 16

Workflow Scenarios

Windows Workflow Foundation includes support for both system workflow and human

workflow across a wide range of scenarios The scenarios include:

• Line of Business application The processing flow or business logic in an extensible

part of the application Vendors implement workflow within their applications to

describe specific business processes, such as inventory processes, that are executed

within the applications

• UI interface page-flow Using a user interface often involves navigating across a set

of linked pages or views with a subset of the variables shared between the views

• Document workflow These are the steps involved in the review and approval of

shared documents or other content The most common document life-cycle

management scenarios include expense report and absence report submission in

which a document is submitted to a workflow involving roles, such as the manager

role, which approve the content before it flows to another system

• Human workflow Human workflow involves coordinating business processes that

involve people Within human workflow, these people communicate with various

systems and other people in a business process implemented in software using a

workflow model

Trang 17

• Business rule workflow In this scenario, complex business logic is well described by

a sequential or state diagram

• Systems management workflow This workflow handles common

systems-management processes

Trang 18

Workflow Authoring Styles and Modes

Authoring Styles

Authoring styles refers to the way workflows are designed in terms of how control of

flow passes through the application Windows Workflow Foundation supports multiple

workflow-authoring styles, including the following:

• Sequential This style is straightforward and useful for repetitive, predictable

operations

• State machine Consists of a set of event-driven states

• Data-driven Relies on data to determine whether certain activities are run or not

based on a local data state

Trang 19

Authoring Modes

Authoring mode refers to how the workflows are actually implemented Windows Workflow Foundation supports the following authoring modes for workflow

implementation:

• Code-only This is the default authoring mode for Windows Workflow

Foundation, and it enables you to use Visual Studio C# or Visual Basic code to specify a workflow by using the Windows Workflow Foundation API set In the code-only workflow, the workflow definition uses code to declare the workflow structure, but designer-emitted code is output to a separate code file, such as

Workflow1.Designer.cs, and encapsulated into the InitializeComponent method

This is similar to the way Windows Forms work

• Code-separation This mode enables you to define workflows using workflow

markup and combine it with Visual Studio C# or Visual Basic code implementations Workflow markup can be generated by a tool or created directly by a workflow author

• No-code This mode enables you to author a workflow by using workflow markup

You can then compile the workflow with the Windows Workflow Foundation command-line workflow compiler, or you can load the workflow markup file into the workflow runtime engine through a host application

Ngày đăng: 14/08/2014, 02:22

TỪ KHÓA LIÊN QUAN