Proxy > Gmail Facebook Yahoo!

What are the differences between WCF and Web Service

WCF has 
[ServiceContract] attribute attached with the class.
WS has 
[WebService] attribute attached with the class.
WCF has 
[OperationContract] attribute attached with methods.
WS has 
[WebMethod] attribute attached with methods.

WCF can be hosted on IIS, WAS, of self-hosting.
WS can be hosted on IIS.
WCF uses 
using System.Runtime.Serialization; namespace for serialization.
WS uses 
using System.Xml.Serialization; namespace for serialization.
WCF support HTTP, TCP, MSMQ, P2P transport protocols.
WS support Http protocol.
WCF supports XML, MTOM (Messaging Transmission Optimization Mechanism), Binary.
WS supports XML, MTOM, DIME (Direct Internet Message Encapsulation).
WCF provides reliable security for messaging and transactions over net.
WS doesn’t provide method level security & message delivery isn’t assured & can be lost without acknowledgement.

Few Important points in WCF

WCF service location that client can use to expose its features

Configuration for Transport protocol, security and encoding mechanism.

It defines type of data and type of operations, a client application can use from WCF service.

Service Contract in WCF

It has 2 attributes: 
[ServiceContract] and [OperationContract]

    public interface IService1
        string GetData(int value);

        CompositeType GetDataUsingDataContract(CompositeType composite);

        // TODO: Add your service operations here
Data Contract in WCF

It has 2 attributes: 
[DataContract]and [DataMember]

// Use a data contract as illustrated in the sample below to add composite types to service operations
    public class CompositeType
        bool boolValue = true;
        string stringValue = "Hello ";

        public bool BoolValue
            get { return boolValue; }
            set { boolValue = value; }

        public string StringValue
            get { return stringValue; }
            set { stringValue = value; }

WCF configurations in config file

It declares information about endpoint name, address, binding and contract.

<?xml version="1.0" encoding="utf-8" ?>
    <compilation debug="true" />
  <!-- When deploying the service library project, the content of the config file must be added to the host's
  app.config file. System.Configuration does not support config files for libraries. -->
      <service name="WcfServiceLibrary1.Service1"behaviorConfiguration="WcfServiceLibrary1.Service1Behavior">
            <add baseAddress ="http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary1/Service1/" />
        <!-- Service Endpoints -->
        <!-- Unless fully qualified, address is relative to base address supplied above -->
        <endpoint address ="" binding="wsHttpBinding" contract="WcfServiceLibrary1.IService1">
              Upon deployment, the following identity element should be removed or replaced to reflect the
              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity
            <dns value="localhost"/>
        <!-- Metadata Endpoints -->
        <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
        <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        <behavior name="WcfServiceLibrary1.Service1Behavior">
          <!-- To avoid disclosing metadata information,
          set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="True"/>
          <!-- To receive exception details in faults for debugging purposes,
          set the value below to true.  Set to false before deployment
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="False" />


0 Respones to "What are the differences between WCF and Web Service"

Send mail to your Friends.  

Expert Feed

Return to top of page Copyright © 2011 | My Code Logic Designed by Suneel Kumar