Monday, March 7, 2011

Publish webservice locally without separate hosting

Hi..

here is a way to deploy web service withing project...
Here are the steps for it



in your Project... right click on Project in Solution Explorer.
Click on Add new Item and Select "Web Service"



Name it as per required... and Click on "Add" Button...

now you have your web service ready in local environment...

put you code in Web Service .Cs file

Build the Source and make sure its error free...

now Deployment Part




Right click on "References" in Solution Exporer,

You will find.. three Options like

  •     Add Reference
  •     Add Web Reference
  •     Add Service Reference

Select "Add Web Reference",

you will get a Pop up,

in Below there are three links
Browse to:

    * Web services in this solution
    * Web services on the local machine
    * Browse UDDI Servers on the local network





select "Web services on the local machine "

You will get a list of Web Services existsing on your local machine


select which one you created in current Project

it will be something like

http://localhost/TempProject/WebService1.asmx



now you will get a list of your methods of the web Service..

if till here everything is fine... that means you are going right....


Congratulations

At right side, in Web Reference Name if wish change the name , that name will be the Service name..

now click on "Add Reference"


now in your project you are able to run your service within your IIS.. without any external Deployment

Now whenever you update the Source of Service class... before building the source one update the Service Reference by right click on Service in Web reference Folder in solution explorer..


To change url of your Service...
  1. Remove Url Value from Settings.
  • Steps
    • In Solution Explorer, In Properties Folder, double click on Settings.settings file
    • remove the path.
    • Now in Web.Config file set your Server path Instead of localhost




Now world is yours...

All The Best



Post a Comment