Welcome to Vishwa's blog - Technology, Spirituality and More...

Could not establish trust relationship for the SSL/TLS

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. [More]

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. [More]

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. [More]

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 words 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 then keep doing trial and error method for hours and days provided you keep your patience on. Once you will find the solution, it will look so easy. [More]

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. [More]

Implementing WCF Service Part 2 - Client

I will consume the Customer WCF Service which I developed in Part 1 on WS* Http Binding, you can implement the best security, transactions and many more things using this way. However, I will consume in a very simplistic way in this post. I assume that you have already deployed the WCF Service under IIS and have a working URL ready to be referenced and you are planning to use the customer WCF service in ASPX web Page. [More]

Implementing WCF Service Part 1 - Service

As you know, the New Windows Communication Services (WCF) will replace the existing ASP.NET ASMX Web Services. So, it will be wise to plan it from today as how to transit in this new service model era. I first tried experimenting with WCF Service almost a year ago with the release of .NET 3.0 but VS 2005 and VISTA did work happily on my machine but now I like VS 2008. I revisited WCF again with the release of .NET 3.5, all the sample available on the web are either old or do not give enough information if you are looking for information as how to use this service in different way over different protocol, which can closely mimic a small real word example . So, I had to spend hours trying to find solutions and put the pieces together. So, I finally thought to create an example to help others who are facing the same situation. I have tried to closely mimic the ASMX Web Service uses, which I posted in my earlier post because most of us will be planning to convert from existing old one. With all the experiments I would give one key Mantra for WCF, dig the Config file specially to understand how to configure BEB (Binding, Endpoint and Behavior). This example deals with CRUD operation on Customer data which I used in earlier post. For the simplicity I am using XML file for the data source and will consume this service with WS* Standard, SOAP based XML POST, Plain Old XML (POX) and HTTP GET and POST. I believe these are the common uses along with TCP, named pipe and MSMQ. [More]

Implementing ASMX Web Service Part 1 - Service

You must be wondering, that in WCF era ASMX Web Service! I wrote the first one 5 years ago and now trying to move them to WCF Service, but lot of companies have not even adopted the web service and some have only started adopting it recently, and now they realized that a new era has come. I will discuss my experiments & experiences with WCF in later posts. However, I would like to post a simple Customer ASMX Web Service and then consume it by a ASP.NET Web Page via Server Side and then Client Side using direct SOAP based XML through HTTP Post. Later, I will create a similar WCF Service with exactly same methods and will access the data exactly same way. Remember this is not a simple HelloWorld Example, this Web Service deals with primitive data type as well as complex one. How far you would like to dive deep into it, will be up to you. [More]

Catch Your Application Errors

You must be thinking that your web site is working great and generating no errors. But have you ever tried catching errors on Application_Error event in Global.asax, it catches all unhandled errors. Try applying the following code, and you will be amazed to see that your site is generating some errors which you were not even aware of. The following method will dump all the erros into a XML file which will be create on montly basis. Initially I was sending these errors to my email, but it is not easy to analyze all the data at once. XML file can be imported in Excel easily and you can fix the code which is generating more errors. [More]