Thursday, May 29, 2008

Secure Query String using Symmetric Cryptography

It is important to secure information on the web specially when transferring data from one page to another. Some information you may not want to make it readable by end user. Microsoft .NET provides Cryptography namespace which can be easily utilized for this purpose. The following example contains a simple class containing Encryption and Decryption method. It supports 2 types – DESC and Rijndael. Symmetric type and encryption key can be configured easily through .config file. Read More

Friday, April 18, 2008

Error: System.ServiceModel.Channels

Recently I came across interesting error messages while calling a WCF Service Hosted in IIS 6.0 on Windows 2003 Server. From the error message, I could not figure out the real cause. But after doing some research and changing few configuration information and changing the code, it appears that these solutions fixed these errors. Read More

Thursday, April 17, 2008

Error: Could not establish trust relationship for the SSL/TLS secure channel with authority

I got this error when calling a WCF Service over HTTPS. A Similar error can also occurs when you try calling a web service programmatically over SSL (HTTPS) and certificate is either not valid or Certificate is attached to a domain and you are not using the domain name but the machine name or IP address. So, what to do in that case if you don’t care about certificate and would like to accept all certificates. I found that it can be done using one of two ways. Read More

Saturday, April 05, 2008

Make a .NET Component accessible in Classic ASP or VB6

I came across a situation again to use exactly same .NET component as COM component in classic ASP page. I had totally forgotten these steps but finally managed to make it work. Later, I thought to put these steps together on my blog, so that if anyone else also don’t know or forget these steps, this will help. Read More

Tuesday, March 25, 2008

Implementing WCF Service Part 5 - Fault Contract

In WCF, there are five major contracts – Service Contract, Operation Contract, Data Contract, Fault Contract and Message Contract. In my previous examples I used first three. In this example, I will implement the Fault Contract. I am not very fond of using Message Contract as some guidelines suggest using the least or based on requirement, however you cannot get away from the first four contracts. In the event of Fault (exception), WCF throws a fault containing detail error message which you may not like to be passed back to the caller. In other words, this example focuses on how to hide full error details and provide a custom error code, message and details. You can use multiple Fault Contracts on one Operation Contract in similar way. This example provides a simple and generic way to handle Faults.
Read More

Thursday, February 07, 2008

Implementing WCF Service Part 4 - POX/REST

This post will focus on implementing POX (Plain Old XML) and REST (Representational State Transfer) in WCF. In other word s this is an implementation of the old HTTP XML Post. I spent not several hours but several days to figure out the solution. As all of you know making HTTP GET is easy in WCF but HTTP Post (without using SOAP) is a different story. I researched all around the web but nowhere found a simple example for this option, yes not even on Microsoft site. Many people just post their opinion in few lines and then you keep guessing, and if you are new to this and keep doing trial and error method for hours and day provided you keep your patience on. Once you will find the solution, it will look so easy. Read More

Saturday, February 02, 2008

Implementing WCF Service Part 3 - SOAP/XML

In this post, I will implement the basicHttpBinding, through which you can even use a HTML page and JavaScript to consume the WCF Service via SOAP based XML. I spent several hours to exactly figure out the SOAP format. In ASMX web service, if you will click on a method, it shows you the sample SOAP format for request and response. Unfortunately, that is not available in WCF Service page right now, so you have to figure out or use a tool to see what is being passed or expected. The Serialization used in ASMX Web Service is based on XML Serialization; however WCF uses a different mechanism for the same. You can use the old SOAP format (which I used in ASMX Web Service) to post the transaction but you will always get SOAP 1.2 format response. In order to keep consistency, I kept the request format similar to response. Read More