9351

Why does the WCF Test Client tool only display a single endpoint baseAdress for multiple endpoints w

Question:

I have the following configuration for my Windows Service hosted WCF service:

<services> <service name="MyService" behaviorConfiguration="MyServiceBehavior"> <endpoint address="" binding="netTcpBinding" bindingConfiguration="WindowsClientOverTcp" name="WindowsClientOverTcp" contract="IMyService" /> <endpoint address="" binding="wsHttpBinding" bindingConfiguration="WindowsClientOverHttps" name="WindowsClientOverHttps" contract="IMyService"> </endpoint> <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" /> <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" /> <host> <baseAddresses> <add baseAddress="https://MyMachine:8250/Services/MyService/Https" /> <add baseAddress="net.tcp://MyMachine:8250/Services/MyService/tcp" /> </baseAddresses> </host> </service>

1st: Everything works. However I have a question. When starting to debug the service in VS.NET 2010 and the "WCF Test Client" tool appears, only the single "net.tcp://MyMachine:8250/Services/MyService/tcp" address is displayed at the top of the tree navigation, and both endpoints displayed as child elements (WindowsClientOverTcp & WindowsClientOverHttps). Now <em>both</em> base addresses are consumable <em>and</em> usable so there is no major issue. However, why is it only showing the single address in the tool? I thought it might be the order displayed in the .config so I switched them around but that didn't change anything.

Anyone know why both base addresses do not display in the WCF Test Client tool when having a single service exposing multiple endpoints?

Thanks!

Answer1:

The WcfTestClient is presenting the service based on the transport of the MEX endpoint you are giving it. If you give the HTTP based endpoint it'll present that one, give the NET.TCP one and that's all it presents.

If you look at WSDL generated by the service, you'll find only the endpoint description for that transport. It's not that WcfTestClient that is limited, its the WSDL.

Answer2:

This thread's answer contains the answer to my original question:

<a href="https://stackoverflow.com/questions/2399865/multiple-base-addresses-and-multiple-endpoints-in-wcf" rel="nofollow">Multiple Base Addresses and Multiple Endpoints in WCF</a>

I was confused that I could create a <em>single</em> service with multiple endpoints and multiple mex endpoints to still behave like 2 services both implementing the same contract. However I do not like this because when you consume my service (either via net.tcp or https) <em>both</em> endpoint configurations are added to the client. I think what I am going to do is create 2 different service configurations, each still implementing the same contract but just with unique names and bindings.

The WCF Test client did a good job of representing exactly what was occuring, based on only reading the single mex endpoint, but yet still exposing both main service endpoints. I don't really like the fact the client gets <em>all</em> the binding configurations when using multiple bindings within a single service (it's not a bad thing, just not the way I intended because a client in my scenario will not switch between binding types mid-way through a single application).

So in conclusion I will break out the configuration to expose (2) services with separate endpoints and their own mex endpoints, so the consuming client (and WCF Test Client) will get only a single endpoint configuration for each address consumed. In order to do this though I have to make some modifications, because 2 service configurations can not point to the same "Service Name" which is the actual class implementing the contract. In my scenario since both services will still implement the same contract I need a way to give them unique names. I added 2 more contracts that inherit from the original contract (1 for each service) and 2 new classes that inherit from the main implementation class. They really don't do anything but create separate placeholders for the WCF service configuration. Then each service configuration has the name of the new class allowing them to be distinct.

And now with this configuration, the WCF Test Client shows each main service endpoint as its own entity. This again does not have to be done if you don't mind the client getting <em>all</em> the endpoint configurations for a single service, but in my case I wanted distinct service addresses, with their single downloaded configuration, yet still implementing the same overall contract.

A little write up on this:

<strong>Exposing Multiple Binding Types For The Same Service Class In WCF:</strong><br /><a href="http://allen-conway-dotnet.blogspot.com/2011/09/exposing-multiple-binding-types-for.html" rel="nofollow">http://allen-conway-dotnet.blogspot.com/2011/09/exposing-multiple-binding-types-for.html</a>

Recommend

  • Android In-app product that is not consumable, but several can be purchased
  • in app purchase - consumable product
  • Why do I have to double run make to fully compile my program? GNU c++
  • How to pivot a dataframe with pandas so variable columns become rows?
  • WCF multiple services same contract in same Config
  • Authenticating using OfficeDev/office-js-helpers rather than adal
  • What changes can I make to a cloud-endpoint (app-engine) return object before I need a new API versi
  • Add new accepted protocol to URL/link validation in SharePoint 2010
  • Obtain access token for both Microsoft Graph and individual service API endpoints (Outlook REST APIs
  • sending email using “bcc” without “to” in java application
  • DotNetOpenAuth - how to uniquely identify Google users?
  • How to set the navigation bar to the top in Table View?
  • Base Internationalization and “Could not find a storyboard named […]”
  • jQueryMobile, Ajax Navigation, and MVC
  • Copying rows in a database when rows have children
  • Passing information to server-side function in a Google Docs Add On
  • Changing references to deprecated methods C++
  • Why doesnt this Java loop in a thread work?
  • Configure nginx to return different files to different authenticated users with the same URI
  • In matplotlib, how do you change the fontsize of a single figure?
  • Spring: No transaction manager has been configured
  • accepts_nested_attributes_for practical form use for in Rails 3
  • Object and struct member access and address offset calculation
  • Copy to all folders batch file?
  • how to display data from 1st point on words on y axis for line chart in d3.js
  • D3 nodes and links from JSON with nested arrays of children
  • Change multiple background-images with jQuery
  • Algorithm for a smudge tool?
  • Xamarin Forms - UWP Fonts
  • How to get address from latitude and longitude android google map v2 [duplicate]
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • Can Jackson SerializationFeature be overridden per field or class?
  • Why doesn't :active or :focus work on text links in webkit? (safari & chrome)
  • When should I choose bucket sort over other sorting algorithms?
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Circular dependency while pushing http interceptor
  • Unanticipated behavior
  • Linker errors when using intrinsic function via function pointer
  • Android Studio and gradle
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET