.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.
- var cred = new TransportClientEndpointBehavior();
- cred.CredentialType = TransportClientCredentialType.SharedSecret;
- cred.Credentials.SharedSecret.IssuerName = "owner";
- cred.Credentials.SharedSecret.IssuerSecret = "SHARED-SECERET";
- var baseAddress = ServiceBusEnvironment.CreateServiceUri("http", "ServiceNAMESpace", "");
- var sh = new ServiceHost(typeof(EchoService), baseAddress);
- var binding = new WS2007HttpRelayBinding(EndToEndSecurityMode.None,RelayClientAuthenticationType.None);
- var endpoint = sh.AddServiceEndpoint(typeof(IEchoService), binding, "Echo");
- //Add SBMetadataBehavior to enable http get metadata via ServiceBus
- sh.Description.Behaviors.Add(new SBMetadataBehavior("metadata"));
I have upload the complete solution so feel free to download and experiment.