Showing posts with label WCF. Show all posts
Showing posts with label WCF. Show all posts

WCF Binding Comparison

Oct 29, 2010 Posted by Lara Kannan 0 comments
WCF Binding Comparison

In my ongoing quest to produce the simplest table possible summarizing the key differences between the various Windows Communication Foundation (WCF) built-in bindings, I came up with the following:









Binding Class Name TransportMessage EncodingMessage VersionSecurity Mode
BasicHttpBindingHTTPTextSOAP 1.1None
WSHttpBindingHTTPTextSOAP 1.2 & WS-A 1.0Message
WSDualHttpBindingHTTPTextSOAP 1.2 & WS-A 1.0Message
WSFederationHttpBindingHTTPTextSOAP 1.2 & WS-A 1.0Message
NetTcpBindingTCPBinarySOAP 1.2Transport
NetPeerTcpBindingP2PBinarySOAP 1.2Transport
NetNamedPipesBindingNamed PipesBinarySOAP 1.2Transport
NetMsmqBindingMSMQBinarySOAP 1.2Message
MsmqIntegrationBindingMSMQX**Not SupportedTransport


Share

Types of Services in WCF

Posted by Lara Kannan 2 comments

There are three types of services in WCF, and they are the following:
  • Typed
  • Untyped
  • Typed message
Typed Service

A typed service is the simplest of services, and is very similar to the methods in a class, in that both the parameters and method return values can be both simple or complex data types.

A typed service can also return a value or return a modified parameter value. The following example illustrates a typed service in which typed operations are used:

[ServiceContract(SessionMode = SessionMode.Required)]
public interface IBookOrder
{

[OperationContract]
void PlaceOrder(string title, decimal cost);

}

This next example shows the use of the ref parameter to return a modified parameter value:

[ServiceContract(SessionMode = SessionMode.Required)]
public interface IBookOrder
{

[OperationContract]
void PlaceOrder(string title, decimal cost, ref ordernumber);

}

Data contracts provide the ability to extend this functionality and accept complex data types as parameters or returned results.

Typed Message Service

A typed message service accepts and returns message information via custom classes that are defined by message contracts. With a typed message service the operation accepts a custom message parameter in the form of a message class, and the responsibility of deciphering the message falls upon the service operation.

The following example shows a service contract along with a defined typed message that is used as a parameter in a typed service operation:

[ServiceContract]
public interface IBookOrder
{

[OperationContract]
void PlaceOrder(Contract MyContract);

}

[MessageContract]
public class MyContract
{

[MessageHeader]
string Title;

[MessageBodyMember]
decimal cost;

}

Untyped Service

Untyped services let you do your work at message level, so this is the most complex of the service types. At this level the service operation accepts and returns message objects so it is recommended that you use this type of service only when you need this level of control, that is, working directly with the message.

The following example shows an operation contract passing a message object as an untyped service operation:

[ServiceContract(SessionMode = SessionMode.Required)]
public interface IBookOrder
{

[OperationContract]
void PlaceOrder(message IncomingMessage);

}

Thanks : codesubmit.com

Share

WCF Service Bindings - Basic

Posted by Lara Kannan 0 comments
Windows Communication Foundation Bindings

This article offers a brief explanation on the basic concepts of the Communication part in the Windows Communication Foundation - WCF. In order to communicate with a WCF service, the client needs to know simple details like 'ABC' of the service.

Whats meant by ABC of WCF ?
Before we learn the ABC of WCF, we need to know how a WCF service is made accessible to the clients.

A WCF service allows communication through an Endpoint. And the endpoint is the only point of communication of the WCF service that enables message exchange with the client as shown in below figure.


And this Endpoint needs to set the ABC attributes of the WCF service as shown in the below figure.


Thus in the WCF world, ABC is an abbreviation of Address, Binding and Contract attributes of an Endpoint.

An example of the Endpoint

Let us quickly run through an example of an endpoint setting in the web.config file at the service side.
<endpoint 
address="http://localhost:8731/EmpWCFService.ServiceImpl.Manager/"
binding="basicHttpBinding"
contract="EmpWCFService.ServiceContract.IEmployee" />

Where,
- address is the network address of the service,
- binding specifies transport protocol (HTTP, TCP, etc.) selected for the service &
- contract is the interface the service implements.

So, what is the Binding?

The Binding is an attribute of an endpoint and it lets you configure transport protocol, encoding and security requirements as shown in the below figure.



Types of Binding

WCF supports nine types of bindings. WCF allows you to transmit messages using different transport protocols (such as HTTP, TCP, and MSMQ) and using different XML representations (such as text, binary, or MTOM).

  1. Basic binding - BasicHttpBinding
    • It is suitable for communicating with ASP.NET Web services (ASMX)-based services that comfort with WS-Basic Profile conformant Web services.
    • This binding uses HTTP as the transport and text/XML as the default message encoding.
    • Security is disabled by default
    • This binding does not support WS-* functionalities like WS- Addressing, WS-Security, WS-ReliableMessaging
    • It is fairly weak on interoperability.
  2. Web Service (WS) binding - WSHttpBinding
    • Defines a secure, reliable, interoperable binding suitable for non-duplex service contracts.
    • It offers lot more functionality in the area of interoperability.
    • It supports WS-* functionality and distributed transactions with reliable and secure sessions using SOAP security.
    • It uses HTTP and HTTPS transport for communication.
    • Reliable sessions are disabled by default.
  3. TCP binding - NetTcpBinding
    • This binding provides secure and reliable binding environment for .Net to .Net cross machine communication.
    • By default it creates communication stack using WS-ReliableMessaging protocol for reliability, TCP for message delivery and windows security for message and authentication at run time.
    • It uses TCP protocol and provides support for security, transaction and reliability.
  4. MSMQ binding - NetMsmqBinding
    • This binding provides secure and reliable queued communication for cross-machine environment.
    • Queuing is provided by using MSMQ as transport.
    • It enables for disconnected operations, failure isolation and load leveling
  5. Peer network binding - NetPeerTcpBinding
    • This binding provides secure binding for peer-to-peer environment and network applications.
    • It uses TCP protocol for communication
    • It provides full support for SOAP security, transaction and reliability.
  6. Duplex WS binding - WSDualHttpBinding
    • This binding is same as that of WSHttpBinding, except it supports duplex service.
    • Duplex service is a service which uses duplex message pattern, which allows service to communicate with client via callback.
    • In WSDualHttpBinding reliable sessions are enabled by default. It also supports communication via SOAP intermediaries.
  7. IPC binding
    • Offered by the NetNamedPipeBinding class, this uses named pipes as a transport for same-machine communication. It is the most secure binding since it cannot accept calls from outside the machine and it supports a variety of features similar to the TCP binding.
  8. Federated WS binding
    • Offered by the WSFederationHttpBinding class, this is a specialization of the WS binding, offering support for federated security.
  9. MSMQ integration binding
    • Offered by the MsmqIntegrationBinding class, this converts WCF messages to and from MSMQ messages, and is designed to interoperate with legacy MSMQ clients.
That's all at this moment. Will see more in the next post.

Thanks : wcftutorial.net & c-sharpcorner.com

Share

Difference between WCF and Web service

Jul 28, 2010 Posted by Lara Kannan 0 comments
Difference between WCF and Web service

Web service is a part of WCF. WCF offers much more flexibility and portability to develop a service when comparing to web service. Still we are having more advantages over Web service, following table provides detailed difference between them.






















































FeaturesWeb ServiceWCF
HostingIt can be hosted in IISIt can be hosted in IIS, windows activation service, Self-hosting, Windows service
Programming[WebService] attribute has to be added to the class[ServiceContraact] attribute has to be added to the class
Model[WebMethod] attribute represents the method exposed to client[OperationContract] attribute represents the method exposed to client
OperationOne-way, Request- Response are the different operations supported in web serviceOne-Way, Request-Response, Duplex are different type of operations supported in WCF
XMLSystem.Xml.serialization name space is used for serializationSystem.Runtime.Serialization namespace is used for serialization
EncodingXML 1.0, MTOM(Message Transmission Optimization Mechanism), DIME, CustomXML 1.0, MTOM, Binary, Custom
TransportsCan be accessed through HTTP, TCP, CustomCan be accessed through HTTP, TCP, Named pipes, MSMQ,P2P, Custom
ProtocolsSecuritySecurity, Reliable messaging, Transactions


Source :www.wcftutorial.net

Hope this will help you!
Share

Difference between BasicHttpBinding and WsHttpBinding

Posted by Lara Kannan 0 comments
Difference between BasicHttpBinding and WsHttpBinding

If we want to summarize in one sentence, the difference between WsHttpBinding and BasicHttpBinding is that WsHttpBinding supports WS-* specification. WS-* specifications are nothing but standards to extend web service capabilities.

Below is a detailed comparison table between both the entities from security, compatibility, reliability and SOAP version perspective.



























































Criteria BasicHttpBinding WsHttpBinding
Security support This supports the old ASMX style, i.e. WS-BasicProfile 1.1. This exposes web services using WS-* specifications.
Compatibility This is aimed for clients who do not have .NET 3.0 installed and it supports wider ranges of clients. Many of the clients like Windows 2000 still do not run .NET 3.0. So older version of .NET can consume this service. As its built using WS-* specifications, it does not support wider ranges of client and it cannot be consumed by older .NET version less than 3 version.
Soap version SOAP 1.1SOAP 1.2 and WS-Addressing specification.
Reliable messaging Not supported. In other words, if a client fires two or three calls you really do not know if they will return back in the same order. Supported as it supports WS-* specifications.
Default security options By default, there is no security provided for messages when the client calls happen. In other words, data is sent as plain text. As WsHttBinding supports WS-*, it has WS-Security enabled by default. So the data is not sent in plain text.
Security options

  • None


  • Windows – default authentication


  • Basic


  • Certificate




  • None


  • Transport


  • Message


  • Transport with message credentials





One of the biggest differences you must have noticed is the security aspect. By default, BasicHttpBinding sends data in plain text while WsHttpBinding sends it in encrypted and secured manner.


To demonstrate the same, lets make two services, one using BasicHttpBinding and the other using WsHttpBinding and then lets see the security aspect in a more detailed manner.



Source : www.codeproject.com

Hope this will help you!
Share

WCF Data Services vs WCF RIA Services

Posted by Lara Kannan 0 comments
To sum up my findings as to the differences between WCF Data Services vs WCF RIA Services.































































WCF (ADO.NET) Data ServicesWCF (.NET) RIA Services
Expose data model as RESTful web servicePrescriptive approach to n-tier app development
Cross platform interoperation as a goal
- “Unlock data silos”
- Out-of-box support from future MS products such as SQL2008 R2, Azure, Excel 2010, SharePoint 2010
Designed specifically for end-to-end Silverlight & ASP.NET solutions
- Some technology proprietary to Silverlight (no WPF support)
- Use ASP.NET Authentication/Roles across SL and ASP.NET
- ASP.NET/AJAX can also access service layer
Loosely coupled clients and serversClient & server are designed and deployed together
Service layer exposes “raw” data sourcesOpportunity to easily add business logic into service layer
- Encourage “domain” concepts
- Strong validation framework
- Offline / Sync enabled
Service can be consumed from .NET, Silverlight, AJAX, PHP and Java (libraries available)Service can be consumed easily from SL, AJAX, WebForms
Service’s data source must:
- Expose at least one IQueryable property
- Implement IUpdateable if you desire updates
Service exposes domain objects via convention:
- IQueryable GetX
- UpdateX/InsertX/DeleteX
No design time experience yet (??)Design time experience with data sources, drag drop etc
- OData for all clients
- Within OData, multiple formats supported (JSON, XML etc)
- SOAP (binary) for SL clients
- JSON for AJAX clients
- SOAP (XML) for other clients
Discoverable (?)Non-discoverable
Hosted as WCF Service (.svc)Old version hosted in custom web handler (.axd).
New version is WCF service.
Standardized on OData protocol Will “support” OData
More mature – public for at least 2 years, formerly “Project Astoria”Less mature – public for 6 months

Common features


  • Based on WCF
  • Use a RESTful architecture
  • Can be used to expose any data source (sql, xml, poco/objects etc.)
  • Client side libraries provide ability to query using LINQ

General


  • Currently they do not share much (any?) technology / code
  • RIA Services is not based on top of Data Services
  • RIA Services & Data Services will “align”
  • OData eventually pushed down into WCF stack
Source : www.mt-soft.com.ar

Hope this will help you!

Share

Free ebook - Pro Windows Server AppFabric

Apr 23, 2010 Posted by Lara Kannan 0 comments
Pro Windows Server AppFabric

This book will teach all about Windows Server AppFabric (code-named “Dublin”),a set of extensions to Windows Server that allow it to function as a lightweight, application server. The combination of Windows Server and AppFabric provides an easy-to-manage platform for developing, deploying, and reliably hosting middle-tier WCF/WF services.

What you’ll learn

  • Deploy Windows Server AppFabric (aka “Dublin”) as your middle-tier application host.

  • Incorporate Windows Server AppFabric’s built-in functionality into your WCF- and WF-based .NET applications.

  • Design your applications to scale and perform in highly available environments, and learn use advanced Windows Server AppFabric features such as content-based and forward routing, long-running transactions, message activity monitoring and tracking.

  • Understand Windows Server AppFabric’s architecture, and know when it is best used, and when you should look at other solutions, such as BizTalk Server.

  • Understand the Windows Server AppFabric roadmap and how AppFabric relates to other new Ms technologies such as .NET 4.0, Oslo, and WCF/WF 4.0

  • Upgrade existing applications to Windows Server AppFabric and take advantage of its architecture and features.

Who this book is for

  • .NET developers (including WCF and WF developers)
  • BizTalk developers



Product Details

  • Paperback: 1016 pages
  • Apress press
  • Language: English
  • ISBN-10: 1430225254
  • ISBN-13: 978-1430225256

Free Download Links :

1. Hotfile Link
http://hotfile.com/.../ProWinsSvAppFabric.rar.html

2. Depositfiles Link
http://depositfiles.com/.../sahe352zq

3. Uploading Link
http://uploading.com/.../Pro.Windows.Server.AppFabric.rar/

4. Oron Link
http://oron.com/bts2vsicmyok/1430228172.rar.html

5. Megaupload Link
http://www.megaupload.com/?d=DWNJ4MBJ


If you like this post, please add your comments and 'A thanks' would be nice.

Thanks : www.downarchive.com

Share

WCF - Interview Questions Part 3

Jun 30, 2009 Posted by Lara Kannan 0 comments
  1. Explain transactions in WCF.
    Transactions in WCF allow several components to concurrently participate in an operation. Transactions are a group of operations that are atomic, consistent, isolated and durable. WCF has features that allow distributed transactions. Application config file can be used for setting transaction timeouts.

  2. What are different isolation levels provided in WCF?
    The different isolation levels:

    1. READ UNCOMMITTED: - An uncommitted transaction can be read. This transaction can be rolled back later.

    2. READ COMMITTED :- Will not read data of a transaction that has not been committed yet

    3. REPEATABLE READ: - Locks placed on all data and another transaction cannot read.

    4. SERIALIZABLE:- Does not allow other transactions to insert or update data until the transaction is complete.

  3. Explain transactions in WCF.
    Transactions in WCF allow several components to concurrently participate in an operation. Transactions are a group of operations that are atomic, consistent, isolated and durable. WCF has features that allow distributed transactions. Application config file can be used for setting transaction timeouts.

  4. How do I serialize entities using WCF?
    LINQ to SQL supports serialization as XML via WCF by generating WCF serialization attributes and special serialization specific logic during code-generation. You can turn on this feature in the designer by setting serialization mode to ‘Unidirectional’. Note this is not a general solution for serialization as unidirectional mode may be insufficient for many use cases.

  5. What is End point ?
    Every service must have Address that defines where the service resides, Contract that defines what the service does and a Binding that defines how to communicate with the service. In WCF the relationship between Address, Contract and Binding is called Endpoint.

    The Endpoint is the fusion of Address, Contract and Binding.


Happy Interview!!!
Share
Labels: ,

WCF - Interview Questions Part 2

Posted by Lara Kannan 0 comments
  1. What is address in WCF and how many types of transport schemas are there in WCF?
    Address is a way of letting client know that where a service is located. In WCF, every service is associated with a unique address. This contains the location of the service and transport schemas. WCF supports following transport schemas

    1. HTTP
    2. TCP
    3. Peer network
    4. IPC (Inter-Process Communication over named pipes)
    5. MSMQ

    The sample address for above transport schema may look like

    http://localhost:81
    http://localhost:81/MyService
    net.tcp://localhost:82/MyService
    net.pipe://localhost/MyPipeService
    net.msmq://localhost/private/MyMsMqService
    net.msmq://localhost/MyMsMqService

  2. What is the difference WCF and Web services?
    1. Web services can only be invoked by HTTP. While Service or a WCF component can be invoked by any protocol and any transport type.

    2. Second web services are not flexible. But Services are flexible. If you make a new version of the service then you need to just expose a new end point. So services are agile and which is a very practical approach looking at the current business trends.

  3. How can we host a service on two different protocols on a single server?
    Let’s first understand what this question actually means. Let’s say we have made a service and we want to host this service using HTTP as well as TCP.

    You must be wondering why to ever host services on two different types of protocol. When we host a service it’s consumed by multiple types of client and it’s very much possible that they have there own protocol of communication. A good service has the capability to downgrade or upgrade its protocol according the client who is consuming him.

    Let’s do a small sample in which we will host the ServiceGetCost on TCP and HTTP protocol.

    Once we are done the server side coding its time to see make a client by which we can switch between the protocols and see the results. Below is the code snippet of the client side for multi-protocol hosting

  4. How does WCF work?
    Follows the 'software as a service' model, where all units of functionality are defined as services.

    A WCF Service is a program that exposes a collection of Endpoints. Each Endpoint is a portal (connection) for communication with either clients (applications) or other services.

    Enables greater design flexibility and extensibility of distributed systems architectures.

    A WCF application is represented as a collection of services with multiple entry points for communications.

  5. What are the main components of WCF?

    1.Service: The working logic or offering, implemented using any .Net Language(C#).

    2.Host: The environment where the service is parked. E.g. exe, process, windows service

    3.Endpoints: The way a service is exposed to outside world.

    Following figure shows us all the core components.

Happy Interview!!!
Share
Labels: ,

WCF - Interview Questions Part 1

Posted by Lara Kannan 0 comments
  1. What is WCF?
    Windows Communication Foundation (WCF) is an SDK for developing and deploying services on Windows. WCF provides a runtime environment for services, enabling you to expose CLR types as services, and to consume other services as CLR types.

    WCF is part of .NET 3.0 and requires .NET 2.0, so it can only run on systems that support it. WCF is Microsoft's unified programming model for building service-oriented applications with managed code. It extends the .NET Framework to enable developers to build secure and reliable transacted Web services that integrate across platforms and interoperate with existing investments.

    Windows Communication Foundation combines and extends the capabilities of existing Microsoft distributed systems technologies, including Enterprise Services, System.Messaging, Microsoft .NET Remoting, ASMX, and WSE to deliver a unified development experience across multiple axes, including distance (cross-process, cross-machine, cross-subnet, cross-intranet, cross-Internet), topologies (farms, fire-walled, content-routed, dynamic), hosts (ASP.NET, EXE, Windows Presentation Foundation, Windows Forms, NT Service, COM+), protocols (TCP, HTTP, cross-process, custom), and security models (SAML, Kerberos, X509, username/password, custom).

  2. What is service and client in perspective of data communication?
    A service is a unit of functionality exposed to the world. The client of a service is merely the party consuming the service.

  3. What is endpoint in WCF? or What is three major points in WCF?
    Every service must have Address that defines where the service resides, Contract that defines what the service does and a Binding that defines how to communicate with the service.

    In WCF the relationship between Address, Contract and Binding is called Endpoint. The Endpoint is the fusion of Address, Contract and Binding.

    1. Address : Specifies the location of the service which will be like http://Myserver/MyService.Clients will use this location to communicate with our service.

    2. Contract : Specifies the interface between client and the server.It's a simple interface with some attribute.

    3. Binding : Specifies how the two paries will communicate in term of transport and encoding and protocols.
  4. What is binding and how many types of bindings are there in WCF?
    A binding defines how an endpoint communicates to the world. A binding defines the transport (such as HTTP or TCP) and the encoding being used (such as text or binary).

    A binding can contain binding elements that specify details like the security mechanisms used to secure messages, or the message pattern used by an endpoint.

    WCF supports nine types of bindings.

    1. Basic binding :
      Offered by the BasicHttpBinding class, this is designed to expose a WCF service as a legacy ASMX web service, so that old clients can work with new services. When used by the client, this binding enables new WCF clients to work with old ASMX services.


    2. TCP binding :
      Offered by the NetTcpBinding class, this uses TCP for cross-machine communication on the intranet. It supports a variety of features, including reliability, transactions, and security, and is optimized for WCF-to-WCF communication. As a result, it requires both the client and the service to use WCF.

    3. Peer network binding :
      Offered by the NetPeerTcpBinding class, this uses peer networking as a transport. The peer network-enabled client and services all subscribe to the same grid and broadcast messages to it.

    4. IPC binding :
      Offered by the NetNamedPipeBinding class, this uses named pipes as a transport for same-machine communication. It is the most secure binding since it cannot accept calls from outside the machine and it supports a variety of features similar to the TCP binding.

    5. Web Service (WS) binding :
      Offered by the WSHttpBinding class, this uses HTTP or HTTPS for transport, and is designed to offer a variety of features such as reliability, transactions, and security over the Internet.

    6. Federated WS binding :
      Offered by the WSFederationHttpBinding class, this is a specialization of the WS binding, offering support for federated security.

    7. Duplex WS binding :
      Offered by the WSDualHttpBinding class, this is similar to the WS binding except it also supports bidirectional communication from the service to the client.

    8. MSMQ binding :
      Offered by the NetMsmqBinding class, this uses MSMQ for transport and is designed to offer support for disconnected queued calls.

    9. MSMQ integration binding :
      Offered by the MsmqIntegrationBinding class, this converts WCF messages to and from MSMQ messages, and is designed to interoperate with legacy MSMQ clients.
  5. What is contracts in WCF?
    In WCF, all services expose contracts. The contract is a platform-neutral and standard way of describing what the service does.

    WCF defines four types of contracts.

    1. Service contracts : Describe which operations the client can perform on the service.

    2. Data contracts : Define which data types are passed to and from the service. WCF defines implicit contracts for built-in types such as int and string, but we can easily define explicit opt-in data contracts for custom types.

    3. Fault contracts : Define which errors are raised by the service, and how the service handles and propagates errors to its clients.

    4. Message contracts : Allow the service to interact directly with messages. Message contracts can be typed or untyped, and are useful in interoperability cases and when there is an existing message format we have to comply with.

Happy Interview!!!
Share
Labels: ,

WCF Performance: Making your service run 3 times faster

Posted by Lara Kannan 0 comments
Wisely changing WCF defaults can yield a significant improvement in your service performance. The exact changes need to be made and their exact effect are dependent in the scenario. The example below how to speed up a certain service 3 times faster.

Read more at http://webservices20.blogspot.com/2009/01/wcf-performance-gearing-up-your-service.html

Share
Labels: ,