ColdFusion and ASP.NET Web Service Interoperability (or Lack Thereof), Part I

For the past few weeks I've been doing some work with a third party service provider trying to integrate their offerings into an in-house application via web services. Their application is written in ASP.NET and ours is written in ColdFusion which has lead to some interesting challenges.

The first issue we had was getting their .NET application to talk to our ColdFusion web service. At first the provider reported that they were seeing the following error when calling our web service:

The underlying connection was closed: An unexpected error occurred on a send.

They were attempting to call our web service every ten minutes, however after looking in our web server logs I was able to determine that they had successfully connected to the web service only once. After doing some research I found a MS Knowledge Base Article which lead me to believe this error was due to a connection timeout. Our server's keep-alive setting was set at 5 minutes. If they were only calling our web service every 10 minutes the connection the client originally opened was being closed by our server. When I pointed out this article and described the issue the provider agreed to have their developers rewrite the calling code in ASP.NET 2.0, which apparently handles the keep-alive properly.

However once the client had been re-written, they reported a new issue. They were now seeing the following error:

The request failed with an empty response.

Just to confirm that the issue wasn't on our end I wrote a quick ColdFusion client which was able to call the web service with no problem. I looked at our logs again and could see that they were not even getting to our web service. This lead me to believe the issue was still in the calling code, but unlike the previous error google didn't turn up anything that seemed to point directly to the issue. At this point I decided to download VB 2005 Express and build a .NET client myself. Having done zero .NET development it took me a few minutes to figure out how to connect to a web service via VB .NET, but once I did it was fairly easy.

In Visual Studio .NET you create a Web Reference to work with web services. Adding a Web Reference is a lot like adding a COM, DLL, or ActiveX reference to you project; basically you just click on Project -> Add Web Reference and type in the URL of the web service you want to work with in the Web Reference window and you are all set. Well almost. Our web service need to be called overSSL so the URL I entered for our Web Reference looked something like "https://our.service.com/component.cfc?wsdl." However whenever I tried to call the web service in my VB client I was getting the same "empty response" error our service provider was reporting. So, I fired up a network sniffer (Ethereal) to see if I could figure out what was going wrong. It turns out that even though I was typing in "https://our.service.com/component.cfc?wsdl" for my Web Reference the VB.NET client was calling "http://our.service.com/component.cfc?wsdl." Security in our application was then trying to redirect the client to the secure URL via <cflocation>, hence the empty response. Now that I knew what the issue was I just had to figure out how to fix it. Turns out it was pretty simple. The VB.NET project has an app.config file which holds, you guessed it, application configuration. One of the entries in this file was the web service URL and upon inspection I found that it was listed as "http://our.service.com/component.cfc?wsdl." I manually edited this entry to use https instead of http and that did the trick. I then notified the provider and they made the corresponding change on their end an we were in business.

This has turned into a bit of a .NET post, but I thought it was worth sharing in case you have others trying to consume your ColdFusion web services via .NET. Up next, what we had to do to get ColdFusion to talk to the service providers .NET web services.

Comments
Hein Mulder's Gravatar Thank you for this solution. I had the same problem and thanks
to you it's solved.
# Posted By Hein Mulder | 7/7/08 8:23 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.