BizTalk Services and "Add Service Reference"
One of the little known features of BizTalk Services is it's support for metadata. There's a sample in the SDK (default path: C:\Program Files\Microsoft BizTalk Services SDK\Samples\Communication\ExploringFeatures\Metadata\MetadataExchange\CS30) that shows you how to listen for incoming metadata requests through the relay. It tracks with the WCF metadata story and is built on WCF extensibility points. In fact, if you open the machine.config file, you will see the policy importers and the WSDL extensions.
The end user experience is quite simple. At some point, you setup the service behavior
<behaviors>
<serviceBehaviors>
<!-- Application Behaviors -->
<behavior name="serviceMetadata">
<serviceMetadata />
</behavior>
</serviceBehaviors>
</behaviors>
Next you define an endpoint - (Notice the binding is the RelayBinding and not the normal metadata binding.)
<endpoint name="MexEndpoint"
contract="IMetadataExchange"
binding="relayBinding"
bindingConfiguration="default"
address="mex" />
That's about all that's required to expose metadata.
Consuming it is just as easy. From a new VS project, all you have to do is right click the project and select "Add Service Reference" (VS 2008).
In the next window, enter the service bus URI (like sb://connect.biztalk.net/services/justinjsmith/Echo) and click Go:
When you click OK, the tooling (think svcutil) will generate the proxy code and config for you. In an empty project, literally the only two lines of code you have to write are:
EchoContractClient client = new EchoContractClient();
Console.WriteLine(client.Echo("hi there"));
Comments
- Anonymous
January 06, 2009
Hi Justin, I always get the "Windows Cardspace" authentication dialog poped up whenever I try to add a Service Reference to my "sb://servicebus.windows.net/services/<SolutionName>/<ServiceName>/<InstanceID>" I want to use the UserName / Password authentication instead of Windows Cardspace as my Service is written in Java using the jdotnetservices. Please let me know your thoughts on it. FYI .. I am using the .Net Services Dec 08 CTP SDK. Best, Mehul