Saturday, August 18, 2007

HTTP ENDPOINT

Both KingPC and Queen computers are Windows Server 2003. They are in the same workgroup: VIP.

Account: Administrator with passsword (password) exists in both computers.

Make sure that both SQL Server 2005 with SP1 installed. If SP1 is not installed, the test will not work from network.

Queen computer has the Visual Studio 2005 installed.
============
Summary
You can create many HTTP ENDPOINT. Each ENDPOINT can have one or more WEB METHOD.
============
To understand the HTTP ENDPOINT, you must be familiar with IIS web hosting. First, ask yourself that how the clients access your web site? I want my clients access my web site as http://queen/sql?wsdl, then you create the following code block:

Work at QUEEN computer:
USE MASTER
sp_reserve_http_namespace N'http://queen:80/sql'
GO
Create ENDPOINT [sql]
STATE=STARTED
AS HTTP (PATH=N'/sql',
PORTS = (CLEAR),
AUTHENTICATION = (INTEGRATED),
SITE=N'queen',
CLEAR_PORT = 80)
FOR SOAP (
WEBMETHOD 'DayAsNumber'(
NAME=N'[master].[sys].[fn_MSdayasnumber]'
, SCHEMA=DEFAULT
, FORMAT=ALL_RESULTS),
WEBMETHOD 'AddUser'( NAME=N'master.sys.sp_adduser'
, SCHEMA=STANDARD
, FORMAT=ALL_RESULTS),
WEBMETHOD 'mgr'(
NAME=N'[AdventureWorks].[dbo].[uspGetEmployeeManagers]'
,SCHEMA=DEFAULT
,FORMAT=ALL_RESULTS),
BATCHES=DISABLED,
WSDL=Default,
DATABASE=N'master',
NAMESPACE=N'http://tempUri.org/',
SCHEMA=STANDARD
)

========

If you want your clients access the HTTP ENDPOINT as http://queen:888/sql?wdsl:

USE MASTER
sp_reserve_http_namespace N'http://queen:888/sql'
GO
Create ENDPOINT [sql888]
STATE=STARTED
AS HTTP (PATH=N'/sql',
PORTS = (CLEAR),
AUTHENTICATION = (INTEGRATED),
SITE=N'queen',
CLEAR_PORT = 888)
FOR SOAP (
WEBMETHOD 'DayAsNumber'(
NAME=N'[master].[sys].[fn_MSdayasnumber]'
, SCHEMA=DEFAULT
, FORMAT=ALL_RESULTS),
WEBMETHOD 'AddUser'( NAME=N'master.sys.sp_adduser'
, SCHEMA=STANDARD
, FORMAT=ALL_RESULTS),
WEBMETHOD 'mgr'(
NAME=N'[AdventureWorks].[dbo].[uspGetEmployeeManagers]'
,SCHEMA=DEFAULT
,FORMAT=ALL_RESULTS),
BATCHES=DISABLED,
WSDL=Default,
DATABASE=N'master',
NAMESPACE=N'http://tempUri.org/',
SCHEMA=STANDARD
)

==========
Work at KingPC:
===========

To access http endpoint at KingPC as http://myServer.vip.com/sql?wdsl

Create a website with the advanced setting as:



Make sure there is a host record in DNS server for myserver.vip.com.USE MASTER

sp_reserve_http_namespace N'http://myserver.vip.com:80/sql'
GO
CREATE ENDPOINT [sql_endpoint1]
STATE=STARTED
AS HTTP (PATH=N'/sql',
PORTS = (CLEAR),
AUTHENTICATION = (INTEGRATED),
SITE=N'myserver.vip.com',
CLEAR_PORT = 80)
FOR SOAP (
WEBMETHOD 'DayAsNumber'( NAME=N'[master].[sys].[fn_MSdayasnumber]'
, SCHEMA=DEFAULT
, FORMAT=ALL_RESULTS),
WEBMETHOD 'GetMaterials'( NAME=N'AdventureWorks.dbo.uspGetBillOfMaterials'
, SCHEMA=STANDARD
, FORMAT=ALL_RESULTS),
BATCHES=DISABLED,
WSDL=Default,
DATABASE=N'master',
NAMESPACE=N'http://tempUri.org/',
SCHEMA=STANDARD)
=======
Test the http endpoints from Visual Studio 2005:

Right Click your project: add web reference.


Test from Internet Explorer 6/7:


However, if you test the http endpoint from Firefox 2.0, you get the following error:


To delete a namespace: http://queen:888/sql
sp_delete_http_namespace_reservation N'http://queen:888/sql

I tried to expose the Extended Stored Procedure but unsuccessful. For example, the master.sys.msver is a extended stored procedure. When you include it in CREATE ENDPOINT, there is no error, but it will not show in IE7 or visual studio 2005.