我想提前承认我在WCF方面不擅长。我正在经历一个WCF多端点,看到一个服务可以有多个端点。
1)在WCF中拥有多个端点有什么好处?
2)查看配置数据并明确注意mex end point
仅用于TCP而不用于其他绑定,为什么?
3)如果服务有多个端点,那么当用户从VS IDE添加服务引用时,则多个端点相关数据暴露&在客户端的配置文件中添加。我们能否以这样的方式设计服务,结果只在客户端显示一个端点相关的地址?假设我有一个服务与HTTP& TCP相关端点,我想当外部客户从他们的VS IDE添加我们的服务,然后他们将看到我们的HTTP端点地址而不是TCP。所以指导我怎么能这样做?如何根据我的要求设计服务端配置文件?
4)我们可以通过这种方式设计WCF服务,我将拥有一项服务和服务。一个合同但我在配置文件中有两个服务标签用于单个服务。假设一个服务端点是HTTP,一个是TCP ...在这种情况下,我们可以指定相同的服务名称和合同名称?任何人都可以为我的情况提供一个示例配置条目,因为我喜欢可视化。
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="MulContractService">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="MulContractBasicBinding" />
</basicHttpBinding>
<netTcpBinding>
<binding name="MulContractTCPBinding" />
</netTcpBinding>
<wsHttpBinding>
<binding name="MulContractWsHttpBinding" />
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="MulContractService" name="MyWCFLibrary.MultipleContract">
<clear />
<endpoint binding="basicHttpBinding" bindingConfiguration="MulContractBasicBinding"
name="MulContractBasicEndPoint" contract="MyWCFLibrary.IMultipleContract"
listenUriMode="Explicit">
<identity>
<dns value="localhost" />
<certificateReference storeName="My" storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
<endpoint address="test1" binding="wsHttpBinding" bindingConfiguration="MulContractWsHttpBinding"
name="MulContractWsHttp" contract="MyWCFLibrary.IByeWorld"
listenUriMode="Explicit">
<identity>
<dns value="localhost" />
<certificateReference storeName="My" storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
<endpoint address="test1" binding="wsHttpBinding" bindingConfiguration="MulContractWsHttpBinding"
name="MulContractWsHttp" contract="MyWCFLibrary.IHelloWorld"
listenUriMode="Explicit">
<identity>
<dns value="localhost" />
<certificateReference storeName="My" storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
<endpoint address="net.tcp://localhost:8733/Design_Time_Addresses/MyWCFLibrary/MultipleContract/"
binding="netTcpBinding" bindingConfiguration="MulContractTCPBinding"
name="MulContractTCPEndPoint" contract="MyWCFLibrary.IMultipleContract" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/MyWCFLibrary/MultipleContract/" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>