Zulfiqar's weblog

Architecture, security & random .Net

Exposing Service metadata via HTTP Get on the Service Bus

Posted by zamd on June 30, 2010

.Net Service Bus currently doesn’t support exposing metadata via HTTP Get. Currently it only supports WS-MetadataExchange based metadata generation. I explored various options and came with following solution which seems to be working fine.

  • Expose a REST endpoint with HTTP Get enabled
  • From the implementation of this endpoint, forward the request to real HTTP Get endpoint
  • Send the response data back to the client via Service Bus
  • I have also used the new .Net 4.0 UseRequestHeadersForMetadataAddressBehavior to fix the port and host name in the generated WSDL file

I have packaged all of the above in a custom service behaviour and you can now enable this feature by simply adding this behaviour (line 16) to your service host.


  1.     var cred = new TransportClientEndpointBehavior();
  2.     cred.CredentialType = TransportClientCredentialType.SharedSecret;
  4.     cred.Credentials.SharedSecret.IssuerName = "owner";
  5.     cred.Credentials.SharedSecret.IssuerSecret = "SHARED-SECERET";
  7.     var baseAddress = ServiceBusEnvironment.CreateServiceUri("http", "ServiceNAMESpace", "");
  9.     var sh = new ServiceHost(typeof(EchoService), baseAddress);
  10.     var binding = new WS2007HttpRelayBinding(EndToEndSecurityMode.None,RelayClientAuthenticationType.None);
  11.     var endpoint = sh.AddServiceEndpoint(typeof(IEchoService), binding, "Echo");
  12.     endpoint.Behaviors.Add(cred);
  14.     //Add SBMetadataBehavior to enable http get metadata via ServiceBus
  15.     sh.Description.Behaviors.Add(new SBMetadataBehavior("metadata"));
  17.     sh.Open();

I have upload the complete solution so feel free to download and experiment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: