/*============================================================================
  File:     Endpoint.sql

  Summary:  This script allows you to use a stored procedure created inside of 
			SQL Server to be accessed from an application directly through an
			HTTP endpoint.

  Date:     April 2005

  Tested on SQL Server Version: 9.00.1116.08 (IDW14 - April CTP)
------------------------------------------------------------------------------
  Copyright (C) 2005 Kimberly L. Tripp, SYSolutions, Inc.
  All rights reserved.

  For more scripts and sample code, check out 
    http://www.SQLskills.com

  This script is intended only as a supplement to demos and lectures
  given by Kimberly L. Tripp.  
  
  THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF 
  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 
  TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  PARTICULAR PURPOSE.
============================================================================*/

USE SimpleDeploy
go

CREATE PROCEDURE [dbo].[Add_Actor]
(
	@Actor NVARCHAR(100)
)
--WITH EXECUTE AS CALLER
AS
	INSERT INTO dbo.Actors VALUES(@Actor)
GO

CREATE ENDPOINT AddActorEndpoint
STATE = STARTED 
AS HTTP 
(
    SITE = '*', 
    PATH = '/AddActorEndpoint',
    AUTHENTICATION = ( INTEGRATED ),
    PORTS = ( CLEAR )
)
FOR SOAP 
(
  WEBMETHOD 'AddActor'
   ( 
     NAME = 'SimpleDeploy.dbo.Add_Actor',
     SCHEMA = STANDARD
   ),
        WSDL = DEFAULT,
        BATCHES = DISABLED,
        DATABASE = 'SimpleDeploy'
)
GO

SELECT * FROM dbo.Actors
GO

SELECT * 
FROM dbo.Actors AS a
  CROSS APPLY dbo.fn_SearchForActor(a.Actor)
GO

SELECT * 
FROM dbo.Actors AS a
  OUTER APPLY dbo.fn_SearchForActor(a.Actor)
GO

-- The prices are correct at the time of the query and are NOT 
-- guaranteed by Amazon (or me :)~

-- OK - the real disclaimer - as per Amazon Web Services Agreement:
-----------------------------------------------------------
--- Price is accurate as of the date/time indicated.	---
--- Prices and product availability are subject to		---
--- change. Any price displayed on the Amazon website	---
--- at the time of purchase will govern the sale of		---
--- this product.										---
-----------------------------------------------------------