windows vista for developers delivery guide phần 6 pdf

21 215 0
windows vista for developers delivery guide phần 6 pdf

Đ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

26 Session 2: Introduction to Microsoft .NET Framework 3.0 Technologies 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. Session 2: Introduction to Microsoft .NET Framework 3.0 Technologies 27 The following classes represent some examples of predefined bindings: Class Description BasicHttpBinding An HTTP protocol binding suitable for connecting to Web services that conforms to the WS-I Basic Profile specification (for example, ASMX- based services) 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 same machine NetMsmqBinding Uses the .NET Framework to create queued message connections with other WCF endpoints Configuring Bindings You can define bindings through code or through configuration. These two approaches are not dependent on the type of binding used, that is, whether you are using a predefined 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. 28 Session 2: Introduction to Microsoft .NET Framework 3.0 Technologies An example of the configuration file is: <configuration> <system.serviceModel> <behaviors> <behavior name="MetaPlusExceptions" > <metadataPublishing enableGetWsdl="true" /> </behavior> </behaviors> <services> <service type="HelloWorld, IndigoConfig, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" serviceBehaviorName="MetaPlusExceptions"> <endpoint address="http://computer:8080/Hello" contract="HelloWorld, IndigoConfig, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" binding="basicHttpBinding" /> </endpoint> </service> </services> <bindings> <basicHttpBinding name="shortTimeout" receiveTimeout="00:00:01" /> </bindings> </system.serviceModel> </configuration> The WinFX Software Development Kit (SDK) includes a tool named SvcConfigEditor, which provides a graphical interface for working with the various <system.serviceModel> settings. Session 2: Introduction to Microsoft .NET Framework 3.0 Technologies 29 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. 30 Session 2: Introduction to Microsoft .NET Framework 3.0 Technologies 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. Session 2: Introduction to Microsoft .NET Framework 3.0 Technologies 31 • 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. 32 Session 2: Introduction to Microsoft .NET Framework 3.0 Technologies 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. Session 2: Introduction to Microsoft .NET Framework 3.0 Technologies 33 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. 34 Session 2: Introduction to Microsoft .NET Framework 3.0 Technologies 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. Session 2: Introduction to Microsoft .NET Framework 3.0 Technologies 35 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. [...]... 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... 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... 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,... 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... file into the workflow runtime engine through a host application Session 2: Introduction to Microsoft NET Framework 3.0 Technologies 45 Using Visual Studio Extensions for Windows Workflow Foundation The Visual Studio Extensions for Windows Workflow Foundation provides a way to graphically create workflow applications using the familiar Visual Studio user interface Workflow applications are composed... to as the workflow runtime engine Although there can be only one workflow runtime engine for every application domain, many workflow instances can run concurrently using a single workflow runtime engine • 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... 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... 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 37 38 Session 2: Introduction to Microsoft NET Framework 3.0 Technologies Developing Workflows by Using the Windows Workflow Foundation Introduction Windows Workflow Foundation provides the programming model... 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... 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 . Programming Windows Workflow Foundation Windows Workflow Foundation consists of the programming model, engine, and tools for quickly building workflow-enabled applications for Windows. Windows. binding suitable for connecting to Web services that conforms to the WS-I Basic Profile specification (for example, ASMX- based services) WSHttpBinding An interoperable binding suitable for connecting. 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,

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

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan