Consuming an ASMX Web Service from a WCF client
As a unified distributed communication platform, WCF can help developers build standard SOAP XML-based Web Services so that traditional XML Web Service clients can consume it. Likewise, it is also quite convenient to use WCF-based client applications for consuming traditional XML Web Services.
In this recipe, we will show you how to consume a traditional ASMX Web Service from a WCF-based client application.
How to do it...
We will use a simple ASMX Web Service as an example here. The complete steps for consuming the sample service are as follows:
Create the sample ASMX Web Service.
The sample ASMX Web Service contains a single operation that returns some string data. The complete definition of the Web Service is shown in the following code snippet.
[WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class TestWebService : System.Web.Services.WebService { [WebMethod] public...