.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> WCF >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Modifying Web service to WCF service

Posted By:Mahesh       Posted Date: April 06, 2011    Points: 200    Category: WCF    URL: http://www.dotnetspark.com  

There are many casses where we wants to use WCF service for the web service created in 2.0 framework, following are the steps by which we can convert Web service to WCF service.
 

First thing you should have .net 3.5/4.0 framework installed on your machine,

1) Give web service class name and web method with ServiceContract and OperationContract atrributes. For this you should add reference System.ServiceModel.dll assembly that is part of .net framework.

it should look like this,

using System.ServiceModel;

[WebService(Namespace = "http://servicepath/")] 
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] 

[ServiceContract(Namespace="http://servicepath")] 
public class myWebService : System.Web.Services.WebService 
{ 
[WebMethod] 
[OperationContract] 
public string HelloWorld(string name) 
{ 
return string.Format("Hello, {0}",name); 
} 
}


2) add this system.serviceModel section into your existing web.config of the asmx web service -



  

    

      

        

        

      

    


    

      

        

          

          

          

          

        

      

    

    

  

  

    

  

3)  you can run the web service now and it should compile and run without issues with asmx extension but one more thing you would have to do to tell .net runtime to use WCF service runtime is add buildprovider under Compilation section.



  

    

      

      

    

  

4> Last but not the least modify your markup code .asmx to have something like this -% @ServiceHost language = "c#" Service="yourNamespace.ClassnameOftheService" %

This shuold help you, running WCF service still keeping the existing asmx extension!

 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend