I’m integrating a product from another vendor with our existing processes.
This product interfaces with our system via an ASP.NET Web Service. As in, I need to write an ASP.NET Web Service that has the particular method names and parameters that the vendor has specified.
Simple enough, but we’re wanting to migrate as much stuff as possible to WCF. I haven’t used WCF much yet, but as I see it it’s the replacement for ASP.NET Web Services (and other things).
Seeing as how I cannot modify the vendor’s product, the only way I could write this new web service using WCF is if a WCF Service can be consumed as if it were an ASP.NET Web Service (i.e., as far as the vendor’s product is concerned, it is consuming an ASP.NET Web Service).
Can WCF Services be consumed in this way?
yes, web services are web services. In general WCF is more flexible and more powerful than ASP.NET, but you can get the on-the-wire message into and out of a WCF service to look exactly the same as the messages for an ASMX service. But, WCF is also different by default.
Migrating should be almost mechanical. Replace the .asmx file containing this:
…with a .svc file containing this:
…and you are nearly done.
But, the default settings for a WCF web service are different than those for an ASP.NET web service. In particular, the XML namespaces of the incoming and outgoing messages may be different. Not everybody specifies distinct xml namespaces for their service and messages, but for those who do, migration will be an issue. The difference in behavior (WCF-vs-ASPNET) will cause apps that successfully were able to call an ASMX service, to not work with a “converted” WCF service.
This article discusses the issue in some detail, and describes a good workaround: use a custom ServiceHost.
The service host code in the article above is incomplete in that it works to fix only the request schema; you might/could also need to do something similar for the response schema.
Good luck.