Tuesday 13 September 2011

creating and consuming Web Service

Steps:
     i. Start the new Web Service project.
     ii. Create the web methods and private stubs which can be accessed only by the web service.
     iii. Build the Service in the release mode.
     iv. Host the Service in the IIS Web Server(IIS 7.0)
     v. Host by,
               a. Go-->Run-->inetmgr.exe
               b. Go--><Machine Name>-->Sites-->DefaultWebSites
               c. Right Click on DefaultWebsites, select 'AddApplication'
               d. Give WebService name and Path where the 'bin' folder is located
               e. Click OK.
               f. Refresh and start the IIS Web Server once.
     vi. To check whether the service is hosted properly, Go to hosted application in IIS Server.
               a. Go-->Sites-->DefaultWebsites--><ServiceName>
               b. Right Click and refresh(if needed), select 'Browse' it will redirect to web service.
     vii. If still not working, check default sites or document,
           for actual service say, service.asmx having business logic(center pane).
     viii. Else, add it manally to default documents.
     ix. Now, Web Service is ready.
Building a wrapper around it, say 'Consumer' for web Service:
     Wrapper for web service can be,
              * Windows application
              * Web application
     Thru Windows application:
              a. Add the Web Service to web reference, use it in the windows client.
     Thru Web application:
              a. Add the Web Service to web reference, use it the web client.

[Note:]
      Publishing the web service (say, release mode) to the respective repository is a good practice.
To Publish the Web service to a common resp. directory,
      i. In MS Visual Studio 2008, Go-->Build-->Publish <Project Name>
      ii. Follow the prompt, lead you to publish the service in the common directory.

No comments:

Post a Comment