<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Write Ahead Blog</title><link>http://blogs.msdn.com/b/rushidesai/</link><description>rushi desai | developer | zune service</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>hello again</title><link>http://blogs.msdn.com/b/rushidesai/archive/2007/11/16/hello-again.aspx</link><pubDate>Sat, 17 Nov 2007 00:40:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6318269</guid><dc:creator>Rushi Desai</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/rushidesai/rsscomments.aspx?WeblogPostID=6318269</wfw:commentRss><comments>http://blogs.msdn.com/b/rushidesai/archive/2007/11/16/hello-again.aspx#comments</comments><description>&lt;P&gt;After missing for over a year I decided to start blogging again. Much has changed. I no longer work in the SQL Server Engine team on Service Broker. I moved to the &lt;A class="" href="http://www.zune.net/" mce_href="http://www.zune.net"&gt;Zune&lt;/A&gt; team to work on web-services that power the Zune marketplace and have been quite busy shipping the newest line of products and services. Keep tuned!&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6318269" width="1" height="1"&gt;</description></item><item><title>External Activator HOWTO</title><link>http://blogs.msdn.com/b/rushidesai/archive/2006/09/25/771240.aspx</link><pubDate>Tue, 26 Sep 2006 01:36:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:771240</guid><dc:creator>Rushi Desai</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/rushidesai/rsscomments.aspx?WeblogPostID=771240</wfw:commentRss><comments>http://blogs.msdn.com/b/rushidesai/archive/2006/09/25/771240.aspx#comments</comments><description>&lt;p&gt;After receiving several requests, I have put together simple documentation on how to use the External Activator sample &lt;a href="http://www.gotdotnet.com/codegallery/codegallery.aspx?id=9f7ae2af-31aa-44dd-9ee8-6b6b6d3d6319"&gt;here&lt;/a&gt;.&lt;span style="font-family:Arial; font-size:1pt"&gt;
		&lt;/span&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=771240" width="1" height="1"&gt;</description></item><item><title>Where did all the images go?</title><link>http://blogs.msdn.com/b/rushidesai/archive/2006/09/25/771055.aspx</link><pubDate>Mon, 25 Sep 2006 23:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:771055</guid><dc:creator>Rushi Desai</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/rushidesai/rsscomments.aspx?WeblogPostID=771055</wfw:commentRss><comments>http://blogs.msdn.com/b/rushidesai/archive/2006/09/25/771055.aspx#comments</comments><description>&lt;P&gt;If you are wondering if the disappearance of images from my blog had anything to do with moving it back to blogs.msdn.com, you are on the right track. The reason I moved the blog was that my computer which was hosting the blog had a RAID-0 failure causing a lot of data to be lost. While all my articles were backed up using SQL Server backup, the images in the filesystem were not being correctly backed up. The images are lost for good. (There are thumbnails still lingering in Live Search and Google's cache, but I haven't figured out if they store full-sized images and whether those can be recovered). So until I recreate all my artwork, you will have to use the text-only mode. &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=771055" width="1" height="1"&gt;</description></item><item><title>Reliably making a web-request from the database</title><link>http://blogs.msdn.com/b/rushidesai/archive/2006/04/19/746827.aspx</link><pubDate>Wed, 19 Apr 2006 18:22:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:746827</guid><dc:creator>Rushi Desai</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/rushidesai/rsscomments.aspx?WeblogPostID=746827</wfw:commentRss><comments>http://blogs.msdn.com/b/rushidesai/archive/2006/04/19/746827.aspx#comments</comments><description>&lt;p&gt;One of the prime use cases of the CLR integration in SQL Server 2005 is to make outbound HTTP requests to web applications or web services. But  how do you do that reliably given the large number of failures that need to be handled ranging from network unavailability, server timeouts, 404 errors, 500 errors, etc. While some of these errors may be transient and we could retry the requests, some may necessitate giving up altogether. This seems like a lot of effort for a user, who just wants to perform a simple web-request.&lt;/p&gt; &lt;p&gt;One solution is to use Service Broker to add reliability. The user can simply begin a dialog and send the request over to a proxy service that handles the task of actually performing the web-request and sending the response back over the dialog. The service could perform all the magic of determining transient errors and retrying requests.&lt;/p&gt; &lt;p&gt;Starting with this idea, I built a sample web proxy service that can be downloaded from the &lt;a href="http://www.gotdotnet.com/codegallery/codegallery.aspx?id=9f7ae2af-31aa-44dd-9ee8-6b6b6d3d6319"&gt; SSB CodeGallery&lt;/a&gt;. The sample comprises of a Service Broker service called WebProxyService which exposes a request/response contract. The contract defines custom message types that marshall HTTP requests and responses into XML. Services like the WebClient service can initiate a dialog to the WebProxyService using this custom contract and send HTTP requests over the dialog.&lt;/p&gt; &lt;p&gt;The WebProxyService itself is implemented as an internally activated stored procedure that uses CLR. Its behavior is controlled by two tables – the RequestFilter table and the ResponseFilter table.&lt;/p&gt; &lt;p&gt;Each row in the RequestFilter table (i.e. a request rule) maps a class of incoming requests (based on method and/or URL pattern) to the action to be taken (deny or accept). If the request is to be accepted, additional columns indicate how the service is to behave in case of failures. The columns of the table are as follows:&lt;/p&gt; &lt;table cellspacing=0 cellpadding=2 style='border: solid black .5pt;'&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;RequestFilterID&lt;/b&gt;&lt;/td&gt; &lt;td&gt;Identifier for the rule&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Method&lt;/b&gt;&lt;/td&gt; &lt;td&gt;HTTP method used in the request – GET, POST, etc&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;UrlPattern&lt;/b&gt;&lt;/td&gt; &lt;td&gt;Regular expression to match URL with&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Timeout&lt;/b&gt;&lt;/td&gt; &lt;td&gt;Amount to wait for HTTP response from target server before failing and retrying&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;NumberOfRetries&lt;/b&gt;&lt;/td&gt; &lt;td&gt;Number of times to try before giving up and failing the request&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;BackoffFactor&lt;/b&gt;&lt;/td&gt; &lt;td&gt;Factor to multiple the Timeout with for each retry. (eg&amp;gt; if RetryDelay = 4 seconds and BackoffFactor is 1.5, we will retry after 4, 6, 9, etc seconds)&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;RetryDelay&lt;/b&gt;&lt;/td&gt; &lt;td&gt;Number of seconds to wait before next retry&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Action&lt;/b&gt;&lt;/td&gt; &lt;td&gt;0 indicates DENY, 1 indicates ACCEPT&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;p&gt;The service maps incoming requests to rules in the RequestFilter. Exact matches (i.e. both Method and UrlPattern match) are preferred to partial matches. If no rules match or if the rule specifies ‘deny’ action, the service ends the conversation on which the request was received with an error declining the request. If there is a matching ‘accept’ rule, the service makes an outbound HTTP request to the Web server with the timeout specified in the rule. If a response is received, it is matched against the ResponseFilter table.&lt;/p&gt; &lt;p&gt;Each row in the ResponseFilter table maps a class of responses (based on the HTTP status code) to the action to be taken (respond, retry or error). The columns of the table are as follows:&lt;/p&gt; &lt;table cellspacing=0 cellpadding=2 style='border:solid black .5pt;'&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;ResponseFilterID&lt;/b&gt;&lt;/td&gt; &lt;td&gt;Identifier for the rule&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;StatusCodeLower&lt;/b&gt;&lt;/td&gt; &lt;td&gt;Lower bound of the status code interval&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;StatusCodeUpper&lt;/b&gt;&lt;/td&gt; &lt;td&gt;Upper bound of the status code interval&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Action&lt;/b&gt;&lt;/td&gt; &lt;td&gt;0 indicates RESPOND, 1 indicates RETRY and 2 indicates ERROR&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;p&gt;If the matching rule indicates ‘respond’, the service marshalls the incoming HTTP response into the XML format and sends it as a message back on the conversation that had sent the request. If the matching rule indicates ‘error’, the service ends the conversation with an error that wraps the status code and message returned by the Web server. If the matching rule indicates ‘retry’, the service saves the original HTTP request to a table indexed by the conversation handle and begins a timer on that conversation with an appropriate interval (calculated as ‘RetryDelay X BackoffFactor^NumberOfRetries’).&lt;/p&gt; &lt;p&gt;When the timer fires (i.e. sends a dialog timer message to the service), the service loads the saved request from the table and tries it again after incrementing the number of retries. Once the request completes (i.e. either a valid response is returned or the number of retries reach maximum), the conversation is ended and the saved request is deleted from the table.&lt;/p&gt; &lt;p&gt;&lt;b&gt;Security Consideration:&lt;/b&gt; SQL allows CLR threads to &lt;a href="http://www.gotdotnet.com/codegallery/codegallery.aspx?id=9f7ae2af-31aa-44dd-9ee8-6b6b6d3d6319"&gt;impersonate&lt;/a&gt; the caller (eg&amp;gt; the user that invokes a CLR stored procedure) in order to allow external access under the security context of that user instead of the security context of the service account running sqlservr.exe. However, in the context of internal activation, there is no concept of a caller. There may be no user interactively logged on to the server and hence there is no way to obtain the security context of any appropriate user. Hence CLR impersonation does not work in internally activated stored procedures. Our HTTP requests will have to be made in the security context of the service account running sqlservr.exe (eg&amp;gt; NETWORK SERVICE or LOCALSYSTEM). If the firewall does not allow the service account user to access the network (or the Internet) for making the HTTP requests, this is bound to fail.&lt;/p&gt; &lt;p&gt;Apart from firewall issues, it may not be such a good idea to use a backend database server for making HTTP requests. First, this requires putting the backend in the DMZ thus exposing it to security threats. Second, making a web-request uses up a database thread that could be doing potentially more important data access work. Hence the recommendation is to use a dedicated instance (even SQL express) to host the WebProxyService. This instance can be placed in the DMZ and it could be running using a Windows account with permission to penetrate the firewall.&lt;/p&gt; &lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=746827" width="1" height="1"&gt;</description></item><item><title>App Paritioning: Data Dependent Routing using Redirection</title><link>http://blogs.msdn.com/b/rushidesai/archive/2005/12/27/746826.aspx</link><pubDate>Wed, 28 Dec 2005 09:37:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:746826</guid><dc:creator>Rushi Desai</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/rushidesai/rsscomments.aspx?WeblogPostID=746826</wfw:commentRss><comments>http://blogs.msdn.com/b/rushidesai/archive/2005/12/27/746826.aspx#comments</comments><description>&lt;P&gt;Following up on my &lt;A href="http://blogs.msdn.com/Default.aspx?tabid=54&amp;amp;EntryID=38"&gt;previous post &lt;/A&gt;regarding how to talk to partitioned services with data dependent routing, here is another mechanism -- redirection. One of the main drawbacks of having the routing service&amp;nbsp;forward&amp;nbsp;messages to the final target service was that you need to delegate trust to the routing service. The target cannot authenticate the initiators directly and so you lose out on the built-in security model.&lt;/P&gt; &lt;P&gt;The other major drawback is if the system is under sufficient load, the routing service&amp;nbsp;could become a bottleneck since all conversations are routed through it and each message in the system must pass through this service.&lt;/P&gt; &lt;P&gt;Using redirection instead of forwarding solves both these problems.&amp;nbsp;I have uploaded a sample to the &lt;A href="http://www.gotdotnet.com/codegallery/codegallery.aspx?id=9f7ae2af-31aa-44dd-9ee8-6b6b6d3d6319"&gt;CodeGallery &lt;/A&gt;to show how to build a routing service that redirects inbound conversations, rather than forwarding incoming&amp;nbsp;messages.&lt;/P&gt; &lt;P align=center&gt;&lt;IMG src="http://blogs.msdn.com/scratch/blog_ddr_redirect.png"&gt; &lt;/P&gt; &lt;P&gt;The above diagram illustrates how the redirecting routing service works. The initiator S1 begins a dialog and sends a message to the routing service. The routing service receives the message (1) and applies the classifier function to obtain the service name and broker instance of the service where this conversation must be redirected to (2). It replies on the same conversation D1 with a redirect message containing the service name and broker instance found (3) and ends the dialog on its end. When the initiator S1 receives the reply, it will end the dialog and begin a new dialog D2 targetting the service name, broker instance specified by the redirect message (4). Finally it will resend the original message to the final destination S2.&lt;/P&gt; &lt;P&gt;It is obvious that since S1 is directly talking to S2, S2 can authenticate S1 and apply the right level of access control. Also once the conversation has been bound to final destination, all subsequent messages will be sent directly, thus freeing the routing service from processing them.&lt;/P&gt; &lt;P&gt;The only limitations of this approach are that the initiators must have routes to the targets and vice versa. Also the contracts need to be extended to include the special 'Redirect' message type and the services should be able to handle them appropriately.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=746826" width="1" height="1"&gt;</description></item><item><title>App Partitioning: Data Dependent Routing and Forwarding</title><link>http://blogs.msdn.com/b/rushidesai/archive/2005/12/22/746825.aspx</link><pubDate>Thu, 22 Dec 2005 16:32:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:746825</guid><dc:creator>Rushi Desai</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/rushidesai/rsscomments.aspx?WeblogPostID=746825</wfw:commentRss><comments>http://blogs.msdn.com/b/rushidesai/archive/2005/12/22/746825.aspx#comments</comments><description>&lt;P&gt;One strategy to achieve scale-out is replicating data. Another is partitioning. Each has its own advantages and limitations; and you’d use one over the other depending on the nature of the data itself as well as the access pattern. While Service Broker naturally provides a mechanism for achieving scale-out when the data is replicated, it is also possible to build highly scalable apps that use partitioned data using Service Broker. The key to achieving this lies in data dependent routing, which is the subject of this post.&lt;/P&gt; &lt;P&gt;But before we go into that topic, let us look at what Service Broker offers for talking to replicated services. The main purpose of routing provided by Service Broker is to decouple the target service specification from its location. When initiating a dialog, the target service is specified using the service name and optionally the broker instance of the target broker (i.e. database). Routes are database objects that help the broker determine where to deliver messages. A route maps a service name and optionally the broker instance with the address of a remote SQL Server instance’s endpoint. So routes enable the user to move services from one database to another without requiring the application to be rewritten. A target service specification may match multiple routes, in which case the broker will chose one of them in a round-robin fashion. This policy can help you to replicate services and distribute load across them.&lt;/P&gt; &lt;P&gt;When the data (and hence the services providing an interface to it) are not replicated but partition, the routing infrastructure will not help. In such a case, you would want your message to be routed based on what is inside it. For example, if there is a table of sales transactions partitioned by region across several databases with a service in each database used for querying the sales information; a request for sales info by region should be routed to the service that is servicing that region. Data dependent routing can be easily implemented as a service that either forwards an incoming conversation or redirects the initiating service to the right destination. In this example, we will look at the design and implementation of a forwarding type data dependent routing service. You can obtain the code from the SSB CodeGallery &lt;A href="http://www.gotdotnet.com/codegallery/codegallery.aspx?id=9f7ae2af-31aa-44dd-9ee8-6b6b6d3d6319"&gt;here&lt;/A&gt;.&lt;/P&gt; &lt;DIV class=SubSubHead&gt;Design&lt;/DIV&gt;&lt;IMG src="http://blogs.msdn.com/scratch/blog_ddr_fwd.png" align=center&gt; &lt;P&gt;The above figure illustrates how the routing service routes and forwards messages. Lets say a service S3 begins a dialog with the routing service and sends it a message (1). When the routing service receives the message, it checks if a mapping exists for this conversation D1 in its mapping table. If no mapping exists, it will invoke the classifier function with the message body to obtain the target service name (2) and then begin a dialog D4 with that service (3). It then creates mappings both for the inbound as well as the outbound conversations (4) and finally it forwards the received message on conversation D4 (5).&lt;/P&gt; &lt;P&gt;If the target service S4 was to send a reply back on the same conversation D4, the routing service would now find mapping for D4 to D3 and simply forward the reply message on D3 without having to classify.&lt;/P&gt; &lt;P&gt;If the routing service receives an “End Dialog” message, it checks if an outbound conversation exists for this conversation and ends it. In either case it will end the inbound conversation. If the routing service receives an “Error” message, it checks if an outbound conversation exists for this conversation and ends it with an error that wraps the incoming error message. It will also end the inbound conversation.&lt;/P&gt; &lt;DIV class=SubSubHead&gt;Implementation&lt;/DIV&gt; &lt;P&gt;The data dependent routing facility is implemented as a service called [&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;urn:rushi.desai.name/RoutingService&lt;/SPAN&gt;]. It uses a table [&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;resolved_conversations&lt;/SPAN&gt;] to store the mapping of inbound to outbound conversations. The service is internally activated to execute the [&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;route_messages&lt;/SPAN&gt;] stored proc. The stored proc implements the logic presented above when it receives an “End Dialog” or “Error” message. When it receives any other type of message, it will invoke a configured stored proc for performing the classification. This stored proc name is stored in the [&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;routing_service_config&lt;/SPAN&gt;] table. You can implement your custom logic in this stored proc which must have the following signature:&lt;/P&gt; &lt;P style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;CREATE&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: blue"&gt;PROCEDURE&lt;/SPAN&gt; your_custom_classifier &lt;SPAN style="COLOR: gray"&gt;(&lt;?xml:namespace prefix = o /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt; &lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;@message_body &lt;SPAN style="COLOR: blue"&gt;VARBINARY&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: fuchsia"&gt;MAX&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;),&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt; &lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;@to_service_name &lt;SPAN style="COLOR: blue"&gt;NVARCHAR&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;256&lt;SPAN style="COLOR: gray"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;OUTPUT&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt; &lt;P&gt;That is, the classifier stored procedure takes in the message body as input and gives the service name as output. You can write the stored procedure in plain T-SQL as well as any CLR language by using SQLCLR hosting and the in-proc managed provider.&lt;/P&gt; &lt;P&gt;I have provided a sample classifier called [&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;sample_classifier&lt;/SPAN&gt;] which basically assumes XML message bodies and looks up the target service in the message itself by running an XQuery on &lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;/message/toServiceName/.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt; &lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt; &lt;DIV class=SubSubHead&gt;Assumptions&lt;/DIV&gt; &lt;OL style="MARGIN-TOP: 0in" type=1&gt; &lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l1 level1 lfo1; tab-stops: list .5in"&gt;The first assumption is that the routing service supports the union of all the contracts supported by the target services. Also the routing broker must contain all the associated message types.&lt;/LI&gt; &lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l1 level1 lfo1; tab-stops: list .5in"&gt;The routing broker (i.e. database) must contain Service Broker routes for all possible target services. So it is basically dependent on dialog level routing to be already setup.&lt;/LI&gt;&lt;/OL&gt; &lt;DIV class=SubSubHead&gt;Limitations&lt;/DIV&gt; &lt;OL style="MARGIN-TOP: 0in" type=1&gt; &lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo2; tab-stops: list .5in"&gt;The first limitation is the security model. In this example, you are basically delegating the routing service to talk to the final target on your behalf. Hence you lose out on end-to-end security. The target service cannot authenticate and authorize the initiator. If this is a requirement, then it might be simpler to use a redirection approach, rather than a forwarding approach. That is, instead of the routing service forwarding messages on your behalf, it should simply classify the message and reply to the initiator with the service name. The initiator can then go begin a new dialog with the resolved target service. A more elaborate approach that maintains end-to-end security but provides forwarding involves using proxy identities. (But that’ll be a subject of another posting).&lt;/LI&gt; &lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo2; tab-stops: list .5in"&gt;The routing service itself can become a bottleneck. Solutions include preferring redirection over forwarding (will discuss this shortly) as well as replicating the routing service in multiple instances and then relying on the round-robin route picking policy to balance the load across the routing services (i.e. ‘m’ initiators talk to ‘n’ replicated routers that talk to ‘l’ partitioned targets).&lt;/LI&gt;&lt;/OL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=746825" width="1" height="1"&gt;</description></item><item><title>Remus joins the blogosphere</title><link>http://blogs.msdn.com/b/rushidesai/archive/2005/12/13/746824.aspx</link><pubDate>Tue, 13 Dec 2005 14:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:746824</guid><dc:creator>Rushi Desai</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/rushidesai/rsscomments.aspx?WeblogPostID=746824</wfw:commentRss><comments>http://blogs.msdn.com/b/rushidesai/archive/2005/12/13/746824.aspx#comments</comments><description>&lt;P&gt;My teammate Remus Rusanu spawned &lt;a href="http://blogs.msdn.com/remusrusanu/"&gt;his blog &lt;/A&gt;today with a &lt;a href="http://blogs.msdn.com/remusrusanu/archive/2005/12/12/502942.aspx"&gt;great article&lt;/A&gt; on how to write a simple publish-subscribe service in SQL Server 2005 using Service Broker. While SQL Server 2005 does not natively support a pub-sub architecture and the only type of conversations provided by the Service Broker are peer-to-peer dialogs, Remus shows how dialogs are a sufficient primitive to implement other types of communication such as pub-sub. So for those of you who have been asking how to build pub-sub using Service Broker, this is a good place to start.&lt;/P&gt; &lt;P&gt;Remus has been heavily involved with answering posts on the SSB forums and has been contributing to the SSB CodeGallery as well. I'm sure his blog will soon be a useful resource for SSB programmers and his articles will fill the void the Write Ahead Blog has been suffering from due to lack of new ideas :-)&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=503043" width="1" height="1"&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=746824" width="1" height="1"&gt;</description></item><item><title>Service Broker official documentation on SQL Server 2005 Books Online</title><link>http://blogs.msdn.com/b/rushidesai/archive/2005/11/04/746823.aspx</link><pubDate>Sat, 05 Nov 2005 08:42:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:746823</guid><dc:creator>Rushi Desai</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/rushidesai/rsscomments.aspx?WeblogPostID=746823</wfw:commentRss><comments>http://blogs.msdn.com/b/rushidesai/archive/2005/11/04/746823.aspx#comments</comments><description>&lt;P&gt;The official documentation for SQL Server 2005 (called 'Books Online') is now available on MSDN. You can read the Service Broker section by clicking on the following link:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;A href="http://msdn2.microsoft.com/en-us/library/ms166043(en-US,SQL.90).aspx"&gt;http://msdn2.microsoft.com/en-us/library/ms166043(en-US,SQL.90).aspx&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=489307" width="1" height="1"&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=746823" width="1" height="1"&gt;</description></item><item><title>[PDC 2005] DAT303 SQL Server 2005: Building Distributed, Asynchronous Database Applications with the Service Broker</title><link>http://blogs.msdn.com/b/rushidesai/archive/2005/09/14/746822.aspx</link><pubDate>Thu, 15 Sep 2005 04:08:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:746822</guid><dc:creator>Rushi Desai</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/rushidesai/rsscomments.aspx?WeblogPostID=746822</wfw:commentRss><comments>http://blogs.msdn.com/b/rushidesai/archive/2005/09/14/746822.aspx#comments</comments><description>&lt;P&gt;You can now download the demos used in Gerald and Roger's PDC talk on the Service Broker from &lt;A href="http://www.gotdotnet.com/codegallery/codegallery.aspx?id=9f7ae2af-31aa-44dd-9ee8-6b6b6d3d6319"&gt;SSB CodeGallery&lt;/A&gt;. The demos include:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;STRONG&gt;Basics &lt;/STRONG&gt;- Creating metadata, beginning a dialog, sending a message and receiving a message. 
&lt;LI&gt;&lt;STRONG&gt;CLR Services&lt;/STRONG&gt; - Writing a CLR stored proc and activating it internally, writing a CLR application and activating it externally (using the External Activator). 
&lt;LI&gt;&lt;STRONG&gt;CG Locking&lt;/STRONG&gt; - Maintaining consistency when concurrent queue readers receive messages from the queue. 
&lt;LI&gt;&lt;STRONG&gt;WCF Channel &lt;/STRONG&gt;- Layering the Windows Communication Foundation ("Indigo") on top of Service Broker by implementing&amp;nbsp; Request/Reply custom transport channels. [This is work in progress and hence we are not releasing this yet]. 
&lt;LI&gt;&lt;STRONG&gt;Remote&lt;/STRONG&gt; - Setting up endpoints and exchanging service listings so that services hosted in different SQL Server instances can talk to each other securely and reliably.&lt;/LI&gt;&lt;/OL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=466286" width="1" height="1"&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=746822" width="1" height="1"&gt;</description></item><item><title>Exporting and importing service listings into a database</title><link>http://blogs.msdn.com/b/rushidesai/archive/2005/09/14/746821.aspx</link><pubDate>Wed, 14 Sep 2005 11:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:746821</guid><dc:creator>Rushi Desai</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/rushidesai/rsscomments.aspx?WeblogPostID=746821</wfw:commentRss><comments>http://blogs.msdn.com/b/rushidesai/archive/2005/09/14/746821.aspx#comments</comments><description>&lt;P&gt;You implemented a Service Broker service and now want others to be able to talk to it. But they will have to first create your message types and contracts to be able to begin a dialog and send messages to your target service. If their service does not reside in the same SQL Server instance, they will have to setup a broker endpoint and setup adjacent layer security to talk to your endpoint. Next they have to setup routing and dialog level security on their side and hand you the public key certificates and reverse route information so that you can setup routing and dialog level security on your side. All this can be quite tedious and prone to errors as some of you may have experienced with BrokerChallege 0. &lt;/P&gt;
&lt;P&gt;To ease this process, we are releasing sample stored procs that can extract all the information needed to talk to your service into an XML file and then on the other side import the service listing XML file into the database. This service listing XML is to Service Broker what WSDL is to Web Services.&lt;/P&gt;
&lt;P&gt;The package contributed by my teammate Remus Rusanu below contains two SQL files: &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;B&gt;ServiceListing.Master.sql:&lt;/B&gt; Run this in the 'master' database. 
&lt;LI&gt;&lt;B&gt;ServiceListing.Database.sql:&lt;/B&gt; Run this in the database to export/import service listing.&lt;/LI&gt;&lt;/UL&gt;
&lt;P class=MsoNormal style="mso-layout-grid-align: none"&gt;
&lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H3&gt;Example of using the Service Broker Service Listing procedures&lt;/H3&gt;
&lt;P&gt;Before starting this example, the Service Broker endpoint has to be created and configured before in order for this example to work. If there is no Service Broker endpoint configured and started, one has to be created. Use &lt;FONT face=courier size=3&gt;select * from sys.service_broker_endpoints&lt;/FONT&gt; to verify if an Service Broker endpoint already exists. If no Service Broker exists, use these steps to create an Service Broker endpoint. Our example will use certificate based Service Broker Transport security. For this, a database master key is required in the &lt;FONT face=courier size=3&gt;master&lt;/FONT&gt; database. Here is a script that creates the Service Broker endpoint: 
&lt;BLOCKQUOTE&gt;&lt;FONT face=courier size=3&gt;&lt;PRE&gt;-- 
-- replace &amp;lt;computer_name&amp;gt; with the actual machine name on which this script is run 
-- 
use Master; 
go 

create certificate [&amp;lt;computer_name&amp;gt;] 
	with subject = N'&amp;lt;computer_name&amp;gt;'; 
go 

create endpoint [ServiceBroker]
	state = started as tcp (listener_port = 4022) for service_broker 
	(authentication = certificate [&amp;lt;computer_name&amp;gt;]); 
go

&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;First, the target service host instance administrator creates a database that will host the target service. A database master key is required for dialog security: 
&lt;BLOCKQUOTE&gt;&lt;FONT face=courier size=3&gt;&lt;PRE&gt;&lt;P&gt;
create database SampleServiceDb;
go

use SampleServiceDb;
create master key encryption by password = '....';
&lt;/P&gt;
&lt;/PRE&gt;&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;The administrator now has to install the Service Listing procedures in the SampleServiceDb. The ServiceListing.Database.sql script has be executed in the SampleServiceDb database. 
&lt;P&gt;After that, the target administrator creates the SampleService and prepares it for dialog security: &lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;FONT face=courier size=3&gt;&lt;PRE&gt;&lt;P&gt;
use database SampleServiceDb;
go

create message type [Sample/Request] validation = well_formed_xml;
create message type [Sample/Reply] validation = well_formed_xml; 
create contract [SampleContract] 
	([Sample/Request] sent by initiator, 
	[Sample/Reply] sent by target);
create queue [SampleQueue]; 
create service [SampleService] on queue [SampleQueue] ([SampleContract]); 
go

exec sp_secure_service [SampleService];
&lt;/P&gt;
&lt;/PRE&gt;&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;Then the administrator exports the service listing for this service: 
&lt;BLOCKQUOTE&gt;&lt;FONT face=courier size=3&gt;&lt;PRE&gt;use database SampleServiceDb;
go

declare @service_listing xml;
exec sp_export_service_listing [SampleService], @service_listing output;
exec sp_save_service_listing @service_listing, N'c:\SampleService.ServiceListing.xml';
go
&lt;/PRE&gt;&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;The service listing was saved in the file &lt;FONT face=courier size=3&gt;c:\SampleService.ServiceListing.xml&lt;/FONT&gt; and it will contain an XML document similar to the following: &lt;FONT color=#0000ff&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;definition&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;xmlns&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;http://schemas.microsoft.com/SQL/ServiceBroker/ServiceListing&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;author&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;REDMOND\rushid&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;timestamp&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;2005-09-13T18:35:08.397&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;version&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;1.0&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;message&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;xmlns&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;http://schemas.microsoft.com/SQL/ServiceBroker/ServiceListing&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;name&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;Sample/Reply&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;validation&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;XML&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;/&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;message&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;xmlns&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;http://schemas.microsoft.com/SQL/ServiceBroker/ServiceListing&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;name&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;Sample/Request&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;validation&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;XML&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;/&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;contract&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;xmlns&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;http://schemas.microsoft.com/SQL/ServiceBroker/ServiceListing&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;name&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;SampleContract&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;message&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;xmlns&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;http://schemas.microsoft.com/SQL/ServiceBroker/ServiceListing&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;name&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;Sample/Request&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;sent-by&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;INITIATOR&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;/&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;message&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;xmlns&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;http://schemas.microsoft.com/SQL/ServiceBroker/ServiceListing&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;name&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;Sample/Reply&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;sent-by&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;TARGET&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;/&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;contract&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;service&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;xmlns&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;http://schemas.microsoft.com/SQL/ServiceBroker/ServiceListing&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;name&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;SampleService&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;broker-instance&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;FDF5116A-F129-48E6-91BB-C9902ECD4601&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;public-access&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;No&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;contract&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;xmlns&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;http://schemas.microsoft.com/SQL/ServiceBroker/ServiceListing&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;name&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;SampleContract&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;/&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;certificate&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;xmlns&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;http://schemas.microsoft.com/SQL/ServiceBroker/ServiceListing&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;issuer-name&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;SampleService&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;serial-number&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;b2 4d 4b 02 93 a7 a8 93 4e c8 24 bd 05 74 6d c0&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;blob&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;MIIBszCCARygAwIBAgIQsk1LApOnqJNOyCS9BXRtwDANBgkqhkiG9w0BAQUFADAYMRYwFAYDVQQDEw1TYW1wbGVTZXJ2aWNlMB4XDTA1MDkxMzE4MzQzOVoXDTA2MDkxMzE4MzQzOVowGDEWMBQGA1UEAxMNU2FtcGxlU2VydmljZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAoEOMkpKAICM168qG5JWXruYnKvEa2saUIxm+OmkE8f5VIthQ4cVaV5adnPKNKjJ/oWYf0v99o82amRNSJqFUCoyxwyNH5A7LCHjNTmIRrZvZb9hxCn66hJhkvZDEWNUFpC4yubokhKaP5gPDE2k8LAVO+KTuqlZi9EPvRcA0Il0CAwEAATANBgkqhkiG9w0BAQUFAAOBgQBFdCGeawEHJg0QD5lLiQ/nzFJfCaRIyc14aZfmr5ywXokMhtmWSzoE7Ty/GfvSXL86JLZsbJ87mAhFhF7px2WGWS0PUCpdE+y84NeZfvq98scnt4XTcjNuhJ46arjKlmX4c4cikp/gfMKmQc+YnzWBtgFolOMo+e7x1HHbTKf6pg==&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;blob&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;certificate&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;service&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;endpoint&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;xmlns&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;http://schemas.microsoft.com/SQL/ServiceBroker/ServiceListing&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;machinename&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;rushi.desai.name&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;tcp-port&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;4023&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;authentication&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;CERTIFICATE&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;encryption&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;NONE, AES&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;public-access&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;No&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;certificate&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;xmlns&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;http://schemas.microsoft.com/SQL/ServiceBroker/ServiceListing&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;issuer-name&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;rushid01 IDENTITY&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;serial-number&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;3e e2 04 5d 08 0b f2 b9 44 67 a0 06 ee aa f7 5d&lt;/FONT&gt;"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;blob&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;MIIBuzCCASSgAwIBAgIQPuIEXQgL8rlEZ6AG7qr3XTANBgkqhkiG9w0BAQUFADAcMRowGAYDVQQDExFydXNoaWQwMSBJREVOVElUWTAeFw0wNTA5MTMxNjA0MDJaFw0wNjA5MTMxNjA0MDJaMBwxGjAYBgNVBAMTEXJ1c2hpZDAxIElERU5USVRZMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQD6U4JDzBDCPLiGHQ3VFEghiw5Rl72HyHODw6+9Y6JtMdhuB3KDf3liRRV5/YZCK2R97cRJXqnTraR/xW9Jx2H7HSmr2nB5NoEF3k/bDeekcrfOHLCggYiyDdVZQXkp7g9Ak7elDjYhjyaYN6CBTGJI+OLlvxSObjXgNWjuD/OD9wIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAN1xjIRYv3sPLX1M91OofdMwG5yQiqOoxIfbdqPwgGwAR4hlJ7zWXncT/UEeBddg6QeNsR2PaMzWW/ZhfI78ji+IMMmmthV9avvZu8AkdaO2fSjiYB54wguksi4SyZAMo5O9gAxOsQs51zPtBYiEz0FQJ+q01GzKhlGpJ/0cyqzk&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;blob&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;certificate&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;endpoint&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT size=3&gt;&lt;FONT color=#800000&gt;definition&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;The file contains all the information needed for a different host to begin dialogs and send requests to this service. Note that there is no secret information in the service listing. The service administrator now sends this information to the administrator of the initiator host. With the service listing received from the target, the initiator admin can start setting up his site for a secure dialog with the target service. First, he creates a database to host the initiator service. A database master key is required for dialog security: 
&lt;BLOCKQUOTE&gt;&lt;FONT face=courier size=3&gt;&lt;PRE&gt;&lt;P&gt;
create database InitiatorServiceDb;
go

use InitiatorServiceDb;
create master key encryption by password = '....';
go
&lt;/P&gt;
&lt;/PRE&gt;&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;The initiator administrator now has to install the Service Listing procedures in the InitiatorServiceDb. The ServiceListing.Database.sql script has be executed in the InitiatorServiceDb database. 
&lt;P&gt;The initiator admin can now import the service listing received from the target service administrator: 
&lt;BLOCKQUOTE&gt;&lt;FONT face=courier size=3&gt;&lt;PRE&gt;&lt;P&gt;
use InitiatorServiceDb;
go

declare @service_listing xml;
exec sp_load_service_listing N'c:\SampleService.ServiceListing.xml', @service_listing output;
exec sp_import_target_service_listing_at_initiator @service_listing, [SampleServiceOwner];
go
&lt;/P&gt;
&lt;/PRE&gt;&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;The import has created the message types, the contract, a route to the target SampleService, a remote service binding, a user that locally represents the owner of the target SampleService and the target SampleService certificate was extracted from the listing and imported into the database. The administrator can now verify that all these completed succesfully: 
&lt;BLOCKQUOTE&gt;&lt;FONT face=courier size=3&gt;&lt;PRE&gt;use InitiatorServiceDb;
go
	
select * from sys.service_message_types;
select * from sys.service_contracts;
select * from sys.routes;
select * from sys.database_principals;
select * from sys.certificates;
select * from sys.remote_service_bindings;
go
&lt;/PRE&gt;&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In addition, if this is the first service listing received from the SQL instance that hosts the target service, the Service Broker transport security also has to be imported: 
&lt;BLOCKQUOTE&gt;&lt;FONT face=courier size=3&gt;&lt;PRE&gt;&lt;P&gt;
--&lt;P&gt;-- replace &amp;lt;target-service-computer-name&amp;gt; with the actual name of the machine hosting the target service&lt;P&gt;--&lt;P&gt;
use InitiatorServiceDb;
go

declare @service_listing xml;
exec sp_load_service_listing N'c:\SampleService.ServiceListing.xml', @service_listing output;
exec master..sp_import_service_listing_grant_connect_on_endpoint @service_listing, '....', [&amp;lt;target-service-computer-name&amp;gt;];
go&lt;/P&gt;

&lt;/PRE&gt;&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The initiator administrator can now create a service that will be used to begin the dialogs with the target service: 
&lt;BLOCKQUOTE&gt;&lt;FONT face=courier size=3&gt;&lt;PRE&gt;use InitiatorServiceDb;
go

create queue [InitiatorQueue];
create service [InitiatorService] on queue [InitiatorQueue];
go

exec sp_secure_service [InitiatorService];
go
&lt;/PRE&gt;&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;The initiator service admin can now export the initiator service listing and send it to the target service admin. This step is needed for two reasons: 
&lt;LI&gt;the target service administrator needs to grant SEND permission on the target service to the initiator service 
&lt;LI&gt;the target service database must contain a route back to the initiator database, so that acks reply messages can arrive back at the initiator 
&lt;P&gt;First, the initiator admin exports the initiator service listing: 
&lt;BLOCKQUOTE&gt;&lt;FONT face=courier size=3&gt;&lt;PRE&gt;use InitiatorServiceDb;
go

declare @service_listing xml;
exec sp_export_service_listing [InitiatorService], @service_listing output;
exec sp_save_service_listing @service_listing, N'c:\InitiatorService.ServiceListing.xml';
go
&lt;/PRE&gt;&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The resulted listing is saved in the &lt;FONT face=courier size=3&gt;c:\InitiatorService.ServiceListing.xml&lt;/FONT&gt; file. The initiator service administrator sends this listing to the target service administrator. The target service administrator can import this listing: 
&lt;BLOCKQUOTE&gt;&lt;FONT face=courier size=3&gt;&lt;PRE&gt;use SampleServiceDb;
go

declare @service_listing xml;
exec sp_load_service_listing N'c:\InitiatorService.ServiceListing.xml', @service_listing output;
exec sp_import_initiator_service_listing_at_target @service_listing, [SampleService], [InitiatorServiceOwner];
go
&lt;/PRE&gt;&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;In addition, if this is the first service listing received from the SQL instance that hosts the initiator service, the Service Broker transport security also has to be imported: 
&lt;BLOCKQUOTE&gt;&lt;FONT face=courier size=3&gt;&lt;PRE&gt;&lt;P&gt;
--&lt;P&gt;-- replace &amp;lt;initiator-service-computer-name&amp;gt; with the actual name of the machine hosting the initiator service&lt;P&gt;--&lt;P&gt;
use InitiatorServiceDb;
go

declare @service_listing xml;
exec sp_load_service_listing N'c:\InitiatorService.ServiceListing.xml', @service_listing output;
exec master..sp_import_service_listing_grant_connect_on_endpoint @service_listing, '....', [&amp;lt;initiator-service-computer-name&amp;gt;];
go&lt;/P&gt;

&lt;/PRE&gt;&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The two systems are now ready to exchange messages. 
&lt;H2&gt;Service Broker Service Listing procedures reference&lt;/H2&gt;
&lt;P&gt;&lt;/P&gt;
&lt;H3&gt;sp_secure_service&lt;/H3&gt;
&lt;BLOCKQUOTE&gt;&lt;FONT face=courier size=3&gt;&lt;PRE&gt;sp_secure_service (
	@service_name as SYSNAME)
&lt;/PRE&gt;&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This utility stored procedure creates a certificate for the service owner. Should be run by both the initiator and target service administrators. It must be run BEFORE exporting the service listing. &lt;BR&gt;Parameters:&lt;/P&gt;
&lt;LI&gt;&lt;FONT face=courier size=3&gt;@service_name&lt;/FONT&gt;: the name of the service to be secured 
&lt;P&gt;Created by: &lt;FONT face=courier size=3&gt;ServiceListing.Database.sql&lt;/FONT&gt;&lt;BR&gt;
&lt;H3&gt;sp_export_service_listing&lt;/H3&gt;
&lt;BLOCKQUOTE&gt;&lt;FONT face=courier size=3&gt;&lt;PRE&gt;sp_export_service_listing (
	@service_name as SYSNAME,
	@service_listing as XML OUTPUT)
&lt;/PRE&gt;&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Will export all the necessary info, including the required certificates, the routing info and the supported contracts/message types for the exported service. A Service Broker endpoint must be configured in order to export the needed routing info. &lt;BR&gt;Parameters:&lt;/P&gt;
&lt;LI&gt;&lt;FONT face=courier size=3&gt;@service_name&lt;/FONT&gt;: the name of the service to be exported 
&lt;LI&gt;&lt;FONT face=courier size=3&gt;@service_listing&lt;/FONT&gt;: output, the service listing XML document 
&lt;P&gt;Created by: &lt;FONT face=courier size=3&gt;ServiceListing.Database.sql&lt;/FONT&gt;&lt;BR&gt;
&lt;H3&gt;sp_import_target_service_listing_at_initiator&lt;/H3&gt;
&lt;BLOCKQUOTE&gt;&lt;FONT face=courier size=3&gt;&lt;PRE&gt;sp_import_target_service_listing_at_initiator (
	@service_listing as XML,
	[@proxy_user_name as SYSNAME],
	[@request_anonymous&lt;/I&gt; as BIT]),
&lt;/PRE&gt;&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;Imports, at the initiator site, a service listing created for a target service. Should be used by the initiator service administrator. It will create the routing info needed to send messages to the target service. It will import the security info needed for targeting the service (the RSB). It will import the contracts and message types used by the target service. &lt;BR&gt;Parameters: 
&lt;LI&gt;&lt;FONT face=courier size=3&gt;@service_listing&lt;/FONT&gt;: the target service listing 
&lt;LI&gt;&lt;FONT face=courier size=3&gt;@proxy_user_name&lt;/FONT&gt;: local name to be used for the target service owner proxy user 
&lt;LI&gt;&lt;FONT face=courier size=3&gt;@requestanonymous&lt;/FONT&gt;: flag to request an anonymous configuration. It cannot be honored if the target service does not accept public access. 
&lt;P&gt;Created by: &lt;FONT face=courier size=3&gt;ServiceListing.Database.sql&lt;/FONT&gt;&lt;BR&gt;
&lt;H3&gt;sp_import_initiator_service_listing_at_target&lt;/H3&gt;
&lt;BLOCKQUOTE&gt;&lt;FONT face=courier size=3&gt;&lt;PRE&gt;sp_import_initiator_service_listing_at_target (
	@service_listing,
	@targeted_service,
	[@proxy_user_name])
&lt;/PRE&gt;&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Imports, at the target site, a service listing created by an initiator. Should be used by the target service administrator. It will import the routing information needed to send back replies to the initiator and the security information needed to grant &lt;FONT face=courier size=3&gt;SEND&lt;/FONT&gt; permission to the initiator service owner. If the initiator service listing does not contain a certificate, no &lt;FONT face=courier size=3&gt;SEND&lt;/FONT&gt; persmission is granted. If anonymous security is desired, the target service administrator should grant &lt;FONT face=courier size=3&gt;SEND&lt;/FONT&gt; permissions on the targeted service to &lt;FONT face=courier size=3&gt;[Public]&lt;/FONT&gt;. &lt;BR&gt;Parameters:&lt;/P&gt;
&lt;LI&gt;&lt;FONT face=courier size=3&gt;@service_listing&lt;/FONT&gt;: the initator service listing 
&lt;LI&gt;&lt;FONT face=courier size=3&gt;@targeted_service_name&lt;/FONT&gt;: the service targeted by the initiator. &lt;FONT face=courier size=3&gt;SEND&lt;/FONT&gt; permission will be granted on this service to the proxy user representing the initiator service owner. 
&lt;LI&gt;&lt;FONT face=courier size=3&gt;@proxy_user_name&lt;/FONT&gt;: name to be used for the proxy user representing the initiator service owner. 
&lt;P&gt;Created by: &lt;FONT face=courier size=3&gt;ServiceListing.Database.sql&lt;/FONT&gt;&lt;BR&gt;
&lt;H3&gt;sp_save_service_listing&lt;/H3&gt;
&lt;BLOCKQUOTE&gt;&lt;FONT face=courier size=3&gt;&lt;PRE&gt;sp_save_service_listing sp_save_service_listing (
	@service_listing as xml,
	@filename as nvarchar(256)
&lt;/PRE&gt;&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Saves a service listing to a file. Size of service listing is limited to 8000 bytes Use sp_export_service_listing to create the service listing The file is overwritten if already exists. &lt;BR&gt;Parameters:&lt;/P&gt;
&lt;LI&gt;&lt;FONT face=courier size=3&gt;@service_listing&lt;/FONT&gt;: the service listing 
&lt;LI&gt;&lt;FONT face=courier size=3&gt;@filename&lt;/FONT&gt;: the fully qualified name of the file 
&lt;P&gt;Created by: &lt;FONT face=courier size=3&gt;ServiceListing.Database.sql&lt;/FONT&gt;&lt;BR&gt;
&lt;H3&gt;sp_load_service_listing&lt;/H3&gt;
&lt;BLOCKQUOTE&gt;&lt;FONT face=courier size=3&gt;&lt;PRE&gt;sp_load_service_listing (
	@filename as nvarchar(256),
	@service_listing as xml output)
&lt;/PRE&gt;&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Loads a service listing to a file. Size of service listing is limited to 8000 bytes. &lt;BR&gt;Parameters:&lt;/P&gt;
&lt;LI&gt;&lt;FONT face=courier size=3&gt;@filename&lt;/FONT&gt;: the fully qualified name of the file 
&lt;LI&gt;&lt;FONT face=courier size=3&gt;@service_listing&lt;/FONT&gt;: output, the service listing 
&lt;P&gt;Created by: &lt;FONT face=courier size=3&gt;ServiceListing.Database.sql&lt;/FONT&gt;&lt;BR&gt;
&lt;H3&gt;sp_import_service_listing_grant_connect_on_endpoint&lt;/H3&gt;
&lt;BLOCKQUOTE&gt;&lt;FONT face=courier size=3&gt;&lt;PRE&gt;sp_import_service_listing_grant_connect_on_endpoint(
	@service_listing as xml,
	@loginpassword nvarchar(max),
	@proxyinstanceuser sysname = NULL,
	@dropexisting as bit = 1)
&lt;/PRE&gt;&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Imports a proxy user for a service host machine and grants &lt;FONT face=courier size=3&gt;CONNECT&lt;/FONT&gt; permission on the broker endpoint. Both initiator service administrator and target service administrator need to do this step. The initator service listing needs to be imported by the target and vice-versa.This step needs to be done only once for each pair of machines. A proxy login will be created to represent the peer service host machine. This login will be granted &lt;FONT face=courier size=3&gt;CONNECT&lt;/FONT&gt; permission on the broker endpoint. Only &lt;FONT face=courier size=3&gt;CERTIFICATE&lt;/FONT&gt; authentication option is supported by this procedure. &lt;BR&gt;Parameters:&lt;/P&gt;
&lt;LI&gt;&lt;FONT face=courier size=3&gt;@service_listing&lt;/FONT&gt;: the service listing 
&lt;LI&gt;&lt;FONT face=courier size=3&gt;@loginpassword&lt;/FONT&gt;: a password is required for the proxy login 
&lt;LI&gt;&lt;FONT face=courier size=3&gt;@proxyinstanceuser&lt;/FONT&gt;: the local name for the proxy user 
&lt;LI&gt;&lt;FONT face=courier size=3&gt;@dropexisting&lt;/FONT&gt;: flag to control the dropping of already existing proxy login, user and certificate 
&lt;P&gt;Created by: &lt;FONT face=courier size=3&gt;ServiceListing.Master.sql&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;You can download the scripts from &lt;A href="http://www.gotdotnet.com/codegallery/codegallery.aspx?id=9f7ae2af-31aa-44dd-9ee8-6b6b6d3d6319"&gt;SSB CodeGallery&lt;/A&gt;.&lt;/P&gt;&lt;/LI&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=465301" width="1" height="1"&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=746821" width="1" height="1"&gt;</description></item></channel></rss>