为什么WCF测试客户端工具仅在调试的时候显示一个端点baseAdress的多个端点? [英] Why does the WCF Test Client tool only display a single endpoint baseAdress for multiple endpoints when debugging?

查看:206
本文介绍了为什么WCF测试客户端工具仅在调试的时候显示一个端点baseAdress的多个端点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的Windows服务以下配置承载WCF服务:

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>  

1日:一切正常。不过,我有一个问题。当开始在VS.NET 2010的服务,调试和WCF测试客户端工具出现,只有一个的net.tcp:// MYMACHINE:8250 /服务/为MyService / TCP地址显示在树的顶部导航和显示为子元素(WindowsClientOverTcp&安培; WindowsClientOverHttps)两个端点。现在的两个的基址是消耗品的的可用因此不存在大问题。但是,它为什么只显示在工具的单一地址?我想这可能是在.config显示的顺序,所以我交换他们周围但这并没有改变任何东西。

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 both base addresses are consumable and 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.

谁知道为什么这两个基地的地址都在WCF测试客户端工具,有一单业务时暴露多个端点不显示?

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

谢谢!

推荐答案

该线程的回答包含了答案,我原来的问题:

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

<一个href="http://stackoverflow.com/questions/2399865/multiple-base-addresses-and-multiple-endpoints-in-wcf">Multiple基址和多个端点的WCF

我很困惑,我可以创造的的多终端,多MEX端点服务仍然表现得像2服务既实现相同的合同。不过,我不喜欢这个,因为当你消费我的服务(通过的net.tcp或HTTPS)的两个的端点配置添加到客户端。我想我会做的是创建2个不同的服务配置,每一个仍然实现相同的合同,但只用唯一的名称和绑定。

I was confused that I could create a single 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) both 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.

WCF测试客户端做了重新presenting一份好工作究竟是发生的历史的基础上,只能读一个MEX终结点,但仍然暴露出两个主要的服务端点。我真的不喜欢的客户端获取事实的所有的绑定配置中的单个服务中使用多个绑定时(这不是一件坏事,只是没有办法的办法我打算,因为在我的方案中的客户端通过一个单一的应用程序绑定类型中途)之间切换。

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 all 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).

所以在最后我会打出来的配置揭露(2)服务具有独立的端点和自己的MEX终结点,所以消费客户机(和WCF测试客户端)将获得只为消耗每个地址的单个端点配置。 为了做到这一点,虽然我不得不作出一些修改,因为2个服务配置不能指向同一个服务名称,这是实际的类实现合同。在我的情况,因为这两项服务将仍然实行相同的合同,我需要一种方式来给他们唯一的名称。我加了2个合同从原来的合同继承(1为每个服务)和2从主实现类继承的新类。他们真的没有做任何事情,但创造的WCF服务配置单独的占位符。然后每个服务配置具有该新类的允许它们是不同的名称。

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.

和现在使用这种配置,WCF测试客户端显示每个主服务端点作为其自己的实体。这又不必做,如果你不介意的客户端得到的所有的端点配置为单一的服务,但对我来说,我想不同的服务地址,以及他们单独下载的配置,但仍然实现相同的总承包。

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 all 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.

一个小写上这样的:

揭露多绑定类型相同的服务类在WCF:
http://allen-conway-dotnet.blogspot.com/2011/09/exposing-multiple-binding-types-for.html

这篇关于为什么WCF测试客户端工具仅在调试的时候显示一个端点baseAdress的多个端点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆