Showing posts with label Web Service. Show all posts
Showing posts with label Web Service. Show all posts

Create Web Service

MS SQL Server 2005 provides us functionality to create web service using HTTP Endpoints. First of all you need to create HTTP ENDPOINT only then HTTP/SOAP can access SQL Server.

Different values that can be used to create web service are:
State can have the following values
  • STARTED Means Listening and Responding
  • DISABLED Means Neither Listening nor Responding 
  • STOPPED Means Listening But Not Responding
HTTP or TCP can be used as transport protocol. AS HTTP Can have following arguments.
  • Path: virtual path on the web server where the webservice will reside.
  • Authentication: it can be of three types

    • INTEGRATED: Most Secure
    • DIGEST: Not Secure
    • BASIC: Least Secure

  • Ports: can be of two types

    • CLEAR: (HTTP - port 80 by default)
    • SSL: (HTTPS - port 443 by default)

  • Site: Name of the server where service is running
Arguments of For SOAP:
  • WEBMETHOD: Name of the Webmethod
  • NAME: write name of the store procedure here
  • BATCHES: can be of two types

    • ENABLED means multiple SOAP request/response message pairs can be identified as part of a single SOAP session
    • DISABLED means only SOAP request/response message pairs can be identified as part of a single SOAP session

  • DATABASE : Write name of the database
  • WSDL: Specify how the Document Generation Will Occur

    • DEFAULT means response to the request will be generated using default format.
    • NONE means no response is generated or returned for query.

  • NAMESPACE: URL of the web service
CREATE ENDPOINT wsUserData
STATE= STARTED
AS HTTP
(
PATH = '/myWebservices'
AUTHENTICATION= INTEGRATED,
PORTS= CLEAR,
SITE='localhot'
)
FOR SOAP
(
WEBMETHOD 'GetUserData'
(NAME='myDB.dbo.GetUserData_sp'),
BATCHES= DISABLED,
WSDL= DEFAULT,
DATABASE = 'myDB',
NAMESPACE= 'http://localhost/myWebservices'
)