Let’s learn to publish Web Service in this C# tutorial. I am assuming you have already created a web service to publish. If not then i would suggest to refer my previous article on how to create a web service application. You can also refer another article that explains how to consume web service.
Publishing a web service in c# & .net is very easy task. Follow below steps to create web service and publish a web service in IIS.
Steps to publish a web service in iis using c#.net
- Open your Web Service Application project. Go to Solution Explorer and right click on your Web Service Project. Select “Publish” from the drop down menu.
Publishing web service through .Net IDE
- A “Publish Web” window will appear.
C# – Publish Web Service Window
- Rename the Publish Profile name from “Profile1” to “MyFirstWebServiceProfile”. Select “File System” as Publish Method. And specify the target location to publish the Web Service. I am keeping target location under “C:\inetpub\wwwroot\MyFirstPublishedWebService”.
C# – Select Profile for Publishing WebService
Click on Publish button to publich the Web Service Application.
- You will find following files and folder in your published folder.
- bin folder – this folder contains the .dll file.
- Web.config file – This is a configuration file.
- Service1.asmx file
- Now open IIS (Internet Information Service).
IIS – Internet Information Service
Here, you can see your published folder under “Default Web Site”. In the next step we would convert it to application format.
- Right click on the published folder and select “Convert to Application”.
IIS – Adding Web Service Application
You can provide different Alias and application pool. The application pool must have a Read Access to the physical path. Hitting on Ok button will publish your Web Service in IIS.
- Now you will need to enable the Directory Browsing of our newly created Web Service Application. While selecting “MyFirstPublishedWebService” application double click on “Directory Browsing”.
IIS – Directory Browsing for WebService
- Click on enable to enable the Directory Browsing.
IIS – Enable Directory Browsing
Now restart the IIS to take effect the changes.
- Now browse “http://localhost/MyFirstPublishedWebService/Service1.asmx” in internet browser. And here is your first published web service interface.
In this article you have learn to publish a web service in IIS using c#. I hope this articles will meet your expectations. If you find this article helpful, then could you please share the article on your social network?
Following articles might be of your interest…
- How to consume the Web Service using Consumer Application.
- How to Create WCF service.
- How to test wcf service using WcfTestClient tool?
- How to consume WCF service.
- How to host wcf service in IIS.
- More articles…