Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Service 服务代理和Web服务_Service_Service Broker - Fatal编程技术网

Service 服务代理和Web服务

Service 服务代理和Web服务,service,service-broker,Service,Service Broker,我想实现一个调用web服务的存储过程(在ServiceBroker基础设施中)。我看了Aschenbrenner关于服务代理的书中的一些例子。但是,我没有找到任何与web服务调用相关的。有人能帮忙吗 谢谢 Sqlbs参见第10章中的第一个示例。如果您的问题是关于实现web服务调用的详细信息,请使用适当的web服务标记而不是service broker标记该问题。我将使用service broker末尾的windows服务(并像在任何win应用程序中一样调用web服务)。不知何故,我不认为从db调

我想实现一个调用web服务的存储过程(在ServiceBroker基础设施中)。我看了Aschenbrenner关于服务代理的书中的一些例子。但是,我没有找到任何与web服务调用相关的。有人能帮忙吗

谢谢
Sqlbs参见第10章中的第一个示例。如果您的问题是关于实现web服务调用的详细信息,请使用适当的web服务标记而不是service broker标记该问题。

我将使用service broker末尾的windows服务(并像在任何win应用程序中一样调用web服务)。不知何故,我不认为从db调用web服务是个好主意


可以找到一个外部激活器。并下载ServiceBroker接口/外部激活器。ServiceBroker接口非常棒!易于使用。

我们公司也有类似的任务,我们找到了一个最佳解决方案,即使用带有外部激活器的异步触发器,从.NET调用Web服务,并在成功调用后取消消息队列。这意味着您创建了一个常规数据库触发器,该触发器将消息发送到ServiceBroker队列进行异步处理。异步触发器。这是克劳斯书第10章的一个例子

-- Create the trigger written with T-SQL
CREATE TRIGGER OnCustomerInserted ON Customers FOR INSERT
AS
DECLARE @conversationHandle UNIQUEIDENTIFIER
DECLARE @fromService SYSNAME
DECLARE @toService SYSNAME
DECLARE @onContract SYSNAME
DECLARE @messageBody XML

SET @fromService = 'CustomerInsertedClient'
SET @toService = 'CustomerInsertedService'
SET @onContract = 'http://ssb.csharp.at/SSB_Book/c10/CustomerInsertContract'

-- Check if there is already an ongoing conversation with the TargetService
SELECT @conversationHandle = ConversationHandle FROM SessionConversations
    WHERE SPID = @@SPID
    AND FromService = @fromService
    AND ToService = @toService
    AND OnContract = @onContract

IF @conversationHandle IS NULL
BEGIN
    -- We have to begin a new Service Broker conversation with the TargetService
    BEGIN DIALOG CONVERSATION @conversationHandle
        FROM SERVICE @fromService
        TO SERVICE @toService
        ON CONTRACT @onContract
        WITH ENCRYPTION = OFF;

    -- Create the dialog timer for ending the ongoing conversation
    BEGIN CONVERSATION TIMER (@conversationHandle) TIMEOUT = 5;

    -- Store the ongoing conversation for further use
    INSERT INTO SessionConversations (SPID, FromService, ToService, OnContract, ConversationHandle)
    VALUES
    (
        @@SPID,
        @fromService,
        @toService,
        @onContract,
        @conversationHandle
    )
END

-- Construct the request message
SET @messageBody = (SELECT * FROM INSERTED FOR XML AUTO, ELEMENTS);

-- Send the message to the TargetService
;SEND ON CONVERSATION @conversationHandle
MESSAGE TYPE [http://ssb.csharp.at/SSB_Book/c10/CustomerInsertedRequestMessage] (@messageBody);
与使用存储过程(通过托管代码(内部激活)调用web服务不同,我们决定最好在sql server之外卸载该处理。发现了这个由微软创建的很好的小工具-
它将侦听激活队列,并在队列中有新消息时启动应用程序。有关实施,请参阅本书中克劳斯的第4章

嗨,谢谢你的笔记。我看了这个例子。它是关于在ServiceBroker基础设施中调用web服务的。我真正需要的是这样的东西:行插入/更新到表->插入/更新触发器触发->触发器将消息写入service broker队列->由SQL Server激活的存储过程->存储过程调用web服务->对话结束。有什么想法吗?Sqlbs