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

04/08/2013

Mtom Encoding in WCF

In this post we will cover
  • What is MTOM Encoding
  • MTOM Vs Text Encoding
  • Reasons to choose MTOM
  • Demo

MTOM (Message Transmission Optimization Mechanism) – WCF supports 3 encodings (in context of WCF, encoding means converting a WCF message (serialized XML InfoSet) into bytes) – Text, MTOM & Binary. All Http Bindings (Basic, WS, Dual, etc.) support Text / MTOM encoding, Text being the default one.

Why MTOM?
Problem with Text Encoding is it uses base 64 encoding format which can inflate the message size by 30%. This can be a heavy penalty while carrying large binary attachments.
On the otherhand, MTOM avoids base 64 encoding for binary attachments keeping the overall size of message in control. Moreover, MTOM is based on open specifications & hence is largely interoperable.

Enough of theory... Let's do a demo to concretize the concept.

For this, i have created a simple WCF service. Below image will describe what we intend to do.





03/07/2013

Using Certificate Authentication for Cross Domain Communication

I have addressed couple of posts on logic behind certificates , how to use them with WCF in both transport and message security contexts.

In this post i try to present the basic idea and implementation of using certificates for communication between different parties in realtime scenario. Dont worry about the screenshots of config files, you can download the sample and get all the settings you required for copy.

There are many scenarios which demand certificates authentication mechanism. Common examples are
#1. Banking web application which do their transactions using FBA and Certificate authentication
#2. Server to Server calls.
#3. Service to Service calls
#4. Application to service calls.
and so on covering most of the high security requirments.

But everything boils down to "A cross domain communication or we can say Domain independent communication".

26/11/2012

Access WCF Service Without Service Reference


                                          Change is Inevitable
This absolutely applies to Client Requirements, but not to our code . In other words, the above statement is one of the 3 design principles of Software architecture.
                                System should be Fault Tolerant.
This means, our system should be adoptable for changes and shouldn't break for every reasonable change.
Reason for bringing up this point is a recent situation i undergo.

13/07/2012

History Behind ASP.NET WEB API

ASP.NET WEB API: 
It is a framework for building and consuming HTTP services that can reach a broad range of clients including browsers and mobile devices. It’s also a great platform for building RESTful services. ASP.NET Web API takes the best features from WCF Web API and merges them with the best features from MVC.
Even before touching code, we need to know why WEB API?

It started with WCF

17/10/2011

WCF - Implementing Message Level Security


Lets start this topic with a comparison between Transport and Message level security.


Transport Level Security
Message Level Security
Scenarios when we should be using one of them
When there are no intermediate systems in between this is the best methodology.  
If it’s an intranet type of solution this is most recommended methodology.
When there are intermediate systems like one more WCF service through which message is routed then message security is the way to go.
Advantages
Does not need any extra coding as protocol inherent security is used.
Performance is better as we can use hardware accelerators to enhance performance.
There is lot of interoperability support and communicating clients do not need to understand WS security as it’s built in the protocol itself.
Does not need any extra coding as protocol inherent security is used.
Performance is better as we can use hardware accelerators to enhance performance.
There is lot of interoperability support and communicating clients do not need to understand WS security as it’s built in the protocol itself.
Disadvantages
As it’s a protocol implemented security so it works only point to point.
As security is dependent on protocol it has limited security support and is bounded to the protocol security limitations.

Needs application refactoring to implement security.
As every message is encrypted and signed there are performance issues.
Does not support interoperability with old ASMX webservices/


So, both Transport and Message level security have their pros and cons.
But, in real time internet scenarios, message level security will be the best pick.

Message Level Security:
Message security uses the WS-Security specification to secure messages. The specification describes enhancements to SOAP messaging to ensure confidentiality, integrity, and authentication at the SOAP message level (instead of the transport level).

11/10/2011

WCF - Implementing Transport Security using SSL


Security :  Security ensures that the information does not go in wrong hands when it travels from the sender to the receiver. This feature ensures that the receiver of the message gets the same information that the sender sends without any data tampering.

There are two types of security provisions in WCF.
1. Transport Level
2. Message Level

Transport level security happens at the channel level. Transport level security is the easiest to implement as it happens at the communication level. WCF uses transport protocols like TCP, HTTP, MSMQ etc and every of these protocols have their own security mechanisms. One of the common implementation of transport level security is HTTPS. HTTPS is implemented over HTTP protocols with SSL providing the security mechanism. No coding change is required it’s more of using the existing security mechanism provided by the protocol.

Message level security is implemented with message data itself. Due to this it is independent of the protocol. Some of the common ways of implementing message level security is by encrypting data using some standard encryption algorithm.
 In this post we will see how to implement transport security on http protocol using SSL certificates.

18/09/2011

WCF and MSMQ


We know Service and Client interact through EndPoints in WCF.












So clients send their request to the service and the service will receive them Via Endpoints. Thus the request will be processed.
Now, what if Service is down by the time client sends a request.
This is where Message Queuing (MSMQ) comes to picture to provide Message reliability. 

This article will describe how to Create / Test one, by providing step by step description. Before we start anything, go to Programs in control panel, open "Turn on/off windows componenets". There enable all the services pertaining to MSMQ. Also ensure that all the services pertaing to Message Queuing are started in services section.

Step 1: Objective
            I want to write a simple service (File Writer) which accepts user info from client and will write a log to a text file. And implement the message reliability using MSMQ.
Step 2: Create Service Contract.
           I defined a Interface for the file writer service. This interface is called "Contract", which will define the basic skeleton of the service.

13/09/2011

WCF Key Points


#1. In WCF Protocol Choice, Message Format, Encoding Format, Hosting Environment, Process Allocation etc, almost everything is configurable and hence called as loosely coupled.

#2. A WSDL (Web Service Description Language) file will define the following details of a WCF service.
  • Provides the information about the service contract and operations available.
  • Provides the information about all the end points exposed by the WCF service.
  •  Provides the information about the messages and types that can be exchanged between the client and the WCF service.
  •  WSDL also provides any information about the policies used.
 #3. Below are the advantages of defining the service contract at Interface level:
  • Defining service contracts using interfaces, removes coupling to service implementation. Later the implementation can be changed at will without affecting the clients.
  • Defining service contracts using interfaces, also allows a service to implement more than 1 contract.