RSS

WCF Learning Note (I)

05 Jan

  1. How to: Define a Windows Communication Foundation Service Contract
    using System; // Step 5: Add the using statement for the System.ServiceModel namespace using System.ServiceModel; namespace Microsoft.ServiceModel.Samples { // Step 6: Define a service contract. [ServiceContract(Namespace = "http://Microsoft.ServiceModel.Samples")] public interface ICalculator { // Step7: Create the method declaration for the contract. [OperationContract] double Add(double n1, double n2); [OperationContract] double Subtract(double n1, double n2); [OperationContract] double Multiply(double n1, double n2); [OperationContract] double Divide(double n1, double n2); } }

  1. How to: Implement a Windows Communication Foundation Service Contract

  2. How to: Host and Run a Basic Windows Communication Foundation Service

    Create a base address for the service.

    Create a service host for the service.

    Enable metadata exchange.

    Open the service host.

  3. How to: Create a Windows Communication Foundation Client.
  4. How to: Configure a Basic Windows Communication Foundation Client
  5. How to: Use a Windows Communication Foundation Client.

A WCF service is a construct that exposes one or more endpoints, each of which exposes one or more service operations. The endpoint of a service specifies an address where the service can be found, a binding that contains the information that a client must communicate with the service, and a contract that defines the functionality provided by the service to its clients.

<client> <endpoint address="http://localhost:8000/ServiceModelSamples/Service/CalculatorService" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ICalculator" contract="Microsoft.ServiceModel.Samples.ICalculator" name="WSHttpBinding_ICalculator"> </endpoint> </client>

 
Leave a comment

Posted by on January 5, 2011 in Dotnet/C#

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: