0

I have a WCF service which I'm consuming using an azure service bus relay. I'm trying to expose the mex endpoint but I'm encountering this error

Could not find a base address that matches scheme sb for the endpoint with binding NetTcpRelayBinding. Registered base address schemes are [http].

My config file looks like this, what am I doing wrong here?

<system.serviceModel>
      <bindings>
         <netTcpRelayBinding>
            <binding name="default">
               <security mode="None" />
            </binding>
         </netTcpRelayBinding>
      </bindings>
      <extensions>
         <behaviorExtensions>
            <add name="transportClientEndpointBehavior" type="Microsoft.ServiceBus.Configuration.TransportClientEndpointBehaviorElement, Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
            <add name="serviceRegistrySettings" type="Microsoft.ServiceBus.Configuration.ServiceRegistrySettingsElement, Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
         </behaviorExtensions>
         <bindingExtensions>
            <!--<add name="basicHttpRelayBinding" type="Microsoft.ServiceBus.Configuration.BasicHttpRelayBindingCollectionElement, Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>-->
            <add name="netTcpRelayBinding" type="Microsoft.ServiceBus.Configuration.NetTcpRelayBindingCollectionElement, Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
         </bindingExtensions>
      </extensions>
      <services>
         <service behaviorConfiguration="serviceMetadata" name="Namespace.TestService">
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            <endpoint address="sb://[my namespace].servicebus.windows.net/Test" behaviorConfiguration="sbTokenProvider" binding="netTcpRelayBinding" bindingConfiguration="default" contract="Namespace.ITestContract" />
            <endpoint name="MexEndpoint" contract="IMetadataExchange" binding="netTcpRelayBinding" bindingConfiguration="default" address="mex" />       
      </service>
      </services>
      <behaviors>
         <serviceBehaviors>
            <behavior name="serviceMetadata">
               <serviceMetadata />
            </behavior>
         </serviceBehaviors>
         <endpointBehaviors>
            <behavior name="sbTokenProvider">
               <transportClientEndpointBehavior>
                  <tokenProvider>
                     <sharedAccessSignature keyName="RootManageSharedAccessKey" key="[key]" />
                  </tokenProvider>
               </transportClientEndpointBehavior>
               <serviceRegistrySettings discoveryMode="Public" />
            </behavior>
         </endpointBehaviors>
      </behaviors>
   </system.serviceModel>

2 Answers 2

1

This is a little tricky because the model how mex endpoints are exposed in WCF is somewhat unfortunate with being inlined into the service itself. With Service Bus, you can't have an endpoint listener listen inside the scope of another listener.

The trick is to have the service endpoint and the mex endpoint sit side-by-side rather than nested, sharing a common base-address, e.g. underneath https://example.servicebus.windows.net/mysvc you'll have "service" and "mex" side-by-side.

I'm in the middle of updating the Relay samples, so the README for this one still needs to be rewritten and it's not yet guaranteed to work, but you might want to take a peek at the App.config and at the Program.cs here. If you want to expose MEX for a NetTcp service you'll need both an https:// and a sb:// prefixed base address.

The sample also shows how to fix up the service debug behavior's help pages.

2
  • Yeah, I ended up doing just this. I created the mex endpoint using a ws2007HttpRelayBinding and it works. But it still does not expose a wsdl, which is what I want to accomplish though.
    – Ejaz
    Commented Jan 5, 2016 at 12:34
  • The "GET" WSDL is produced by the debug behavior, so you may want to check out how I fixed that up, Commented Jan 5, 2016 at 12:44
0

You need to declare a base address compatible with mexHttpBinding (by the way http). 2 solutions are possible:

1/ Add a baseAddress in host section inside service as below :

<service ...>
   ...
   <host>
      <baseAddresses>
          <add baseAddress="http://localhost:8080/Test" />
      </baseAddresses>
   </host>
</service>

Your mex endpoint will listen on http://localhost:8080/Test/mex.

2/ -or- simply add a full address in your mex endpoint.

<endpoint address="http://[namespace].servicebus.windows.net/Test/mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
1
  • I already have an endpoint with mexHttpBinding. What I want to do is to expose it over the service bus. Adding a base address is not helping.
    – Ejaz
    Commented Dec 29, 2015 at 17:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.