Convert .asmx file to WCF .svc file to create simple API web service
by
on October 19th, 2009 at 10:50 PM (1242 Views)
1) Introduction
This is part of a series of blogs. The others are:-
2) A simple .asmx file and calling a function
3) Converting a .asmx file to WCF .svc file
I had some time on my hands recently and for one reason or another starting looking into web services and WCF. It was about a week ago and I can’t remember the exact reason why I started, but I thought I’d detail the pitfalls, hair pulling, shouting and swearing moments into a blog to help others out.
I’ve previously used .asmx web services within my ASP.NET applications, called them using Javascript and then handled the response using a Javascript function. There are a variety of ways of utilising .asmx services in ASP.NET applications. I just happened down this particular route as I found it very fast.
I’ve always been interested in cross internet communicating, sending and receiving messages between domains and all that sort of thing. Specifically coming from a Financial Advice background there is an industry standard communication schema that is used to updates details between systems and I was interested to know how this worked.
I was reading up on Windows Communication Foundation (WCF) [1,2,3] and, as it seemed WCF is designed to replace a number of different web services, I thought I’d have a go at converting one of my .asmx files to a WCF file just as a bit of a test. Here starts a long and treacherous path!!
I don’t know if my terminology is right here, but I wanted to develop it as an API so that the service can be called from a variety of clients.
This process involved a lot of playing around with code and testing and, frankly, I can’t remember all the various elements I tried, but have tried to detail, as clearly as possible, what I have done.
These articles aren’t meant as a technical exposé of WCF, more a practical example of getting a service to work.
I’ve broken the process down into some distinct areas that should, hopefully, follow through the process so you can see the changes that are made and how it’s constructed. The first thing we’ll start with is a simple .asmx file and calling a function within it.
Next: A simple .asmx file
References
1) WCF vs ASMX WebServices
2) InfoQ: ASMX or WCF Web Services?
3) Thom Robbins .NET Weblog : Integrating WCF with your existing ASMX Services








Email Blog Entry