Learning WCF Chapter2 Service Contracts

A service contract describes
the operations supported by a service,
the message exchange pattern they use,
and the format of each message.

The service contract is also the main driver for generating a service description.
A valid WCF service implements at least one service contract.
The following attributes play an important role in defining service contracts:
ServiceContractAttribute, OperationContractAttribute,and MessageParameterAttribute.

Collectively,these attributes provide control over the way messages are formatted.
In this section,the first thing you’ll do is complete a lab that exercises each of these attributes.
Following the lab,I’ll summarize the features of each of these attributes and their roles in service contract design.
In the process,I’ll also cover other related concepts such as:
• How service contracts map to WSDL elements
• Service contract design
• Operations signatures and messages
• Versioning scenarios

Lab: Designing a Service Contract

In this lab,you will begin with an existing solution that includes three projects: a service,a host,and a client.
The solution includes a working implementation of a very simple service contract,
and you will edit this implementation to exercise more control over the service contract to control the resulting service description.
In the process, you’ll also test service contract version tolerance.

Exploring service contract compatibility
In the first part of this lab,you’ll modify an existing service contract to use an explicit contract name and namespace
while testing compatibility between proxy and service as changes are made.
1. Start by opening the solution for this lab: <YourLearningWCFPath>\Labs\Chapter2\ServiceContracts\ServiceContracts.sln.

2. Test the solution first to see that it works.
Compile the solution and run the Host project followed by the WinClient project.
From the WinClient application interface,click each button to test the two operations exposed by the service contract: Operation1( ) and Operation2( ).

3. Review how the service you just tested is implemented.
Go to the BusinessServices project and open IServiceA.cs. Example 2-3 shows the service contract,which defines two operations.

时间: 2024-10-05 11:04:10

Learning WCF Chapter2 Service Contracts的相关文章

Learning WCF Chapter2 Service Description

While messaging protocols are responsible for message serialization formats,there must be a way to capture the protocols required to communicate between clients and services. In Chapter 1,you worked with WSDL documents,which describe the requirements

Learning WCF Chapter2 Data Contracts

A data contract describes how CLR types map to XSD schema definitions. Data contracts are the preferred way to enable serialization of complex types included in operation signatures as parameters or return values. You create a data contract by applyi

Learning WCF Chapter2 WCF Contracts and Serialization

So far I’ve talked about the standards behind it all,but in fact WCF hides most of this from the developer by providing a programming interface for designing service contracts and controlling the message format. Application messaging requirementsare

Learning WCF Chapter2 Messaging Protocols

In Chapter 1,you were introduced to fundamental WCF concepts,      在章节1中,学习了wcf中的基础概念including how to create and consume a service,           包括如何创建以及调用服务how to host a service and expose endpoints where it can be reached by clients,    如何托管服务,使得客户端可以

Learning WCF Chapter1 Generating a Service and Client Proxy

In the previous lab,you created a service and client from scratch without leveraging the tools available to WCF developers. Although this helps you to understand the raw requirements for sending messages between clients and services,in reality,develo

Learning WCF Chapter1 Creating a New Service from Scratch

You’re about to be introduced to the WCF service. This lab isn’t your typical “Hello World”—it’s “Hello Indigo”! In this lab,you will learn how to build a new WCF service and in the process learn the minimum requirements of service development and co

Learning WCF Chapter1 Exposing Multiple Service Endpoints

So far in this chapter,I have shown you different ways to create services,how to expose a service endpoint and metadata exchange endpoint,how to generate client proxies,how to work with metadata,and how to configure service behaviors. In this section

WCF Windows Service Using TopShelf and ServiceModelEx z

http://lourenco.co.za/blog/2013/08/wcf-windows-service-using-topshelf-and-servicemodelex/ There are two excellent .NET libraries that help us to build enterprise solutions using the Windows Communication Foundation (WCF) – TopShelf and ServiceModelEx

Learning WCF Chapter1 Summary

SummaryThis chapter covered a lot of ground,beginning with a look at the purpose of WCF,the problems it solves and its alignment with SOA,through discussion of the fundamentals developers should know before they begin working with WCF. I also touched