WCF development example wizard Part 1-classic recommendation!

Source: Internet
Author: User
WCF Development example wizard Part 1 --- Classic recommendation!This article briefly introduces Windows communication Foundation (WCF) and how to call the WCF Service in an application, which is very suitable for beginners of WCF. --- CodeProject.com is a classic recommendation of the WCF development wizard !!! Http://forum.EntLib.com open source ASP. NET Forum team dedication. WCF IntroductionWindows Communication Foundation (WCF) is an extension of the. NET Framework to create Interconnected Systems. WCF provides a unified framework for creating secure, reliable, and transaction services. It integrates and extends Development Technologies of existing distributed systems, such as Microsoft. net Remoting, Web Services, and Web Services Enhancements (WSE) to develop a unified and reliable system. The WCF framework can implement loosely coupled applications in the SOA architecture,

WCF simplifies the construction of SOA architecture applications, and reduces development complexity by unifying Enterprise Services, Messaging,. Net Remoting, Web Services, WSE, and other technologies. The WCF Service can be configured through Attribute to improve flexibility and efficiency. It supports a large number of Web Services standards, such as XML, XSD, SOAP, Xpath, and WSDL, such as WS-Addressing, WS-Policy, WS-Security, WS-Trust, WS-Secure, WS-Reliable Messaging, WS-Atomic Transaction, and WS-Coordination. Depicts the Windows communication Foundation (WCF) framework model:

WCF Communication Model

WCF establishes communications between applications according to the customer/server model, and the client directly accesses the service through the Endpoints endpoint published by the server. Endpoints is an address for sending or receiving messages. Each Service can have multiple Endpoints.

The WCF Service is composed of the following main components, indicating how these components interact:
  • Service Contract
  • Operation Contract
  • Data Contract
  • Data Member

Service ContractService Contract defines the message direction and type in a session, and subscribes to the Service Contract of WCF using an interface or class. Service Contract is a channel for external applications to access the Service method. In a Service, there should be at least one ServiceContract. ServiceContract is defined as follows: [ServiceContract] public interface IWCFForumService {[OperationContract] string GetMessage (int messageID); [OperationContract] IEnumerable GetMessageInfo (int messageID);} http://forum.EntLib.com open source ASP. NET Forum team remarks: The sample code here uses the Open Source Forum EntLib_BBS database, you can easily switch to other databases.
ServiceContract attribute of the preceding interface indicates that this is a Service Contract. At the same time, Service Contract defines available methods in the Service. Methods in the WCF Service are similar to those in Web services. IWCFForumService is the Forum Service interface. All OperationContract methods of the Service are published to the external system.Operation ContractOperation Contract defines the methods provided to external systems in the WCF Service. OperationContract attribute needs to be applied to these methods, just like the Web method in Web services. For the example code of Operation Contract, see IWCFForumService interface definition.Data ContractData Contract defines a series of DataMember, which is used in ServiceContract as a Composite type. Use DataContract attribute to define Data Contract for a class. Data Contract must be serialized by serializer. By applying DataMember attribute to member variables, DataMember member variables must be serialized. MessageInfo-Data Contract is defined as follows:
[DataContract]
Public class MessageInfo
{
Private int _ messageID;
Private DateTime _ postedDate;
Private string _ message; [DataMember]
Public int MessageID
{
Get {return _ messageID ;}
Set {_ messageID = value ;}
} [DataMember]
Public DateTime PostedDate
{
Get {return _ postedDate ;}
Set {_ postedDate = value ;}
} [DataMember]
Public string Message
{
Get {return _ message ;}
Set {_ message = value ;}
}
}Data MemberDataMember attribute can be applied to Private member variables (Private member) and can be accessed through serialization and deserialization. For the usage of DataMember, refer to the MessageInfo definition above.

The following content... (-WCF development example wizard Part 2 --- classic recommendation !) ---- Including downloading sample programs!

Reference:1. Codeproject.com, Windows Communication Foundation (WCF) Overview, by Deepthi viswanw.nairhttp: // www.codeproject.com/KB/WCF/WCFOverview.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.