惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Securelist
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Google DeepMind News
Google DeepMind News
N
News and Events Feed by Topic
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - Franky
T
Threat Research - Cisco Blogs
罗磊的独立博客
IT之家
IT之家
人人都是产品经理
人人都是产品经理
Stack Overflow Blog
Stack Overflow Blog
K
Kaspersky official blog
博客园_首页
T
The Blog of Author Tim Ferriss
T
Tenable Blog
I
InfoQ
Apple Machine Learning Research
Apple Machine Learning Research
T
The Exploit Database - CXSecurity.com
D
Docker
TaoSecurity Blog
TaoSecurity Blog
S
Schneier on Security
Attack and Defense Labs
Attack and Defense Labs
N
News and Events Feed by Topic
M
MIT News - Artificial intelligence
U
Unit 42
N
Netflix TechBlog - Medium
L
LINUX DO - 热门话题
C
CERT Recently Published Vulnerability Notes
T
Tailwind CSS Blog
Hacker News: Ask HN
Hacker News: Ask HN
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
爱范儿
爱范儿
美团技术团队
F
Fortinet All Blogs
Last Week in AI
Last Week in AI
AWS News Blog
AWS News Blog
V
V2EX
博客园 - 【当耐特】
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Hacker News - Newest:
Hacker News - Newest: "LLM"
Schneier on Security
Schneier on Security
腾讯CDC
H
Help Net Security
B
Blog RSS Feed
T
Tor Project blog
P
Privacy & Cybersecurity Law Blog
The Last Watchdog
The Last Watchdog
有赞技术团队
有赞技术团队

博客园 - 蒋建华

使用SharePoint 2010 Management Shell修改SharePoint 2010 身份认证方式的两种方法 推荐几款兼容移动终端和PC终端的UI控件 八大免费SharePoint MasterPage 和Theme 一个完整的微软官方提供的SharePoint 2010 完整模板 Sample Master Pages for SharePoint 2010 Windows 7下安装SharePoint Server 2010指南 将PD的物理模型导入Erwin 使用PowerDesigner 15生成SQL Server中文注释 Workflow4 持久化之数据库模型 私有云、公有云与传统数据中心 ORM及相关技术概念入门 SharePoint 2010企业应用解决方案 微软云计算解决方案之特性及案例分析 不竭动力:云计算中虚拟化管理详解 云协作新利器:微软SharePoint Online 云计算版的PC管理工具:Windows Intune PetShop与ORM架构的比较 私有云:构建DDC测试环境需求分析 教你如何安装配置动态数据中心测试环境
使用Create EndPoint创建本机XML Web Service
蒋建华 · 2011-11-07 · via 博客园 - 蒋建华
 

.Net 平台下的应用中,应用对内(外)的访问往往通过Web Service来实现,当然现在也可以使用WCF。大多数情况下,Web Service都是宿主在IIS上的,但是从SQL Server 2005起,我们可以在SQL Server 2005中发布本机XML Web Service,这样我们可以像访问宿主在IISWeb Service一样来访问SQL ServerXML Web Service

   注:在SQL Server 2008/R2中,已经不推荐使用本机XML Web Service,将会被WCFASP.Net所取代,在本文中只探讨如何定义和使用本机XML Web Service。参见:

http://msdn.microsoft.com/zh-cn/library/cc280436.aspx

虽然在SQL Server的未来版本中,本机XML Web Service将不存在,从技术爱好的角度来看,我们还是有必要了解一下这项技术,因为使用SQL Server 本机XML Web Service可以快速方便的把自定义函数或者存储过程转化为Web服务接口暴露出来。

要在SQL Server中实现本机XML Web Service,需要3个步骤:

1.       创建存储过程(已访问存储过程的Web Service方法为例), Create Procedure

2.       保留命名空间, sp_reserve_http_namespace

3.       创建访问端点,Create Endpoint

下面我们以微软的实例数据库AdventureWorks为例,把访问AddressType表的存储过程转化成Web Service,下面来详细说明。

1.创建存储过程

CREATE PROCEDURE dbo.PersonAddressTypeProc

    -- Add the parameters for the stored procedure here

AS

BEGIN

    -- SET NOCOUNT ON added to prevent extra result sets from

    -- interfering with SELECT statements.

    SET NOCOUNT ON;

    -- Insert statements for procedure here

    SELECT [AddressTypeID]

      ,[Name]

      ,[rowguid]

      ,[ModifiedDate]

 FROM [AdventureWorks].[Person].[AddressType]

END

GO

2.保留命名空间

sp_reserve_http_namespace N'http://localhost:80/AddressType'

这里我们将要创建的命名空间是:http://localhost/AddressType,如果没有执行sp_reserve_http_namespace,而去直接创建访问端点,那么会提示命名空间没有被创建或不存在。有关sp_reserve_http_namespace的更多内容可以访问:

http://msdn.microsoft.com/en-us/library/ms190614.aspx

4.       创建访问端点

5. Create Endpoint GetAddressType

6. State = Started

7. AS Http

8. (

9. path='/AddressType',

10. Authentication =(INTEGRATED),

11. ports =(CLEAR),

12. site ='localhost'

13.)

14.For SOAP

15.(

16. WebMetHod 'AddressTypeList'(Name ='AdventureWorks.dbo.PersonAddressTypeProc'),

17. Batches = disabled,

18. wsdl = default,

19. database ='AdventureWorks',

20. NAMESPACE = 'http://localhost:80/AddressType'

21.)

22.   GO

有关Create Endpoint的参数,感兴趣的读者可以参考:

http://msdn.microsoft.com/zh-cn/library/ms181591.aspx

在本文中,对语句及其参数并不做详细解释,有关详细解释大家可以参考《SQL SERVER 2005本机Web服务支持(实战篇)》,这里就不赘述了。下面给出完整代码:

-- ================================================

-- Template generated from Template Explorer using:

-- Create Procedure (New Menu).SQL

--

-- Use the Specify Values for Template Parameters

-- command (Ctrl-Shift-M) to fill in the parameter

-- values below.

--

-- This block of comments will not be included in

-- the definition of the procedure.

-- ================================================

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

-- =============================================

-- Author:    <Author,,Name>

-- Create date: <Create Date,,>

-- Description:   <Description,,>

-- =============================================

CREATE PROCEDURE dbo.PersonAddressTypeProc

    -- Add the parameters for the stored procedure here

AS

BEGIN

    -- SET NOCOUNT ON added to prevent extra result sets from

    -- interfering with SELECT statements.

    SET NOCOUNT ON;

    -- Insert statements for procedure here

    SELECT [AddressTypeID]

      ,[Name]

      ,[rowguid]

      ,[ModifiedDate]

 FROM [AdventureWorks].[Person].[AddressType]

END

GO

sp_reserve_http_namespace N'http://localhost:80/AddressType'

Create Endpoint GetAddressType

    State = Started

AS Http

(

    path='/AddressType',

    Authentication =(INTEGRATED),

    ports =(CLEAR),

    site ='localhost'

)

For SOAP

(

    WebMetHod 'AddressTypeList'(Name ='AdventureWorks.dbo.PersonAddressTypeProc'),

    Batches = disabled,

    wsdl = default,

    database ='AdventureWorks',

    NAMESPACE = 'http://localhost:80/AddressType'

)

GO