如何一起使用netTcpBinding和netMsmqBinding?

时间:2016-07-15 14:23:03

标签: wcf wcf-binding

I am trying to use both tcp as well as msmq but it gives an error msmq doesn't support dual binding or it's not properly configured, how to solve this issue? 
I have created two end points. 

I tried to do something like this 



  <?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="Binding_Config" receiveTimeout="00:10:00" sendTimeout="00:10:00" openTimeout="00:02:30">
          <security mode="None">
            <transport clientCredentialType ="None" protectionLevel="None"></transport>
            <message clientCredentialType="None"/>
          </security>
        </binding>
      </netTcpBinding>

      <netMsmqBinding>
        <binding name="ServiceBinding" durable="true" exactlyOnce="true" useActiveDirectory="false" receiveTimeout="00:10:00" sendTimeout="00:10:00" openTimeout="00:02:30" >
          <security mode="None">
            <transport
               msmqAuthenticationMode="None"
               msmqProtectionLevel="None"

              />
          </security>
        </binding>
      </netMsmqBinding>
    </bindings>

    <services>
      <service name="WCFLib.SignalService"
        behaviorConfiguration = "SignalServiceMEXBehavior">
        <endpoint address ="TradeSignalService"
        binding="netTcpBinding"
        contract="TradeServiceLib.ITradeSignalService" bindingConfiguration="Binding_Config"/>
        <!-- Enable the MEX endpoint -->

        <!-- Need to add this so MEX knows the address of our service -->


        <endpoint  address="net.msmq://localhost/private/FirstQueue" binding="netMsmqBinding" contract="TradeServiceLib.ITradeSignalService" bindingConfiguration="ServiceBinding"/>
        <!--<endpoint address="mex" binding="netTcpBinding" contract="IMetadataExchange"/>-->


        <host>
          <baseAddresses>
            <add baseAddress ="http://192.168.1.125:2344"/>
            <add baseAddress ="net.tcp://192.168.1.125:2348"/>
          </baseAddresses>
        </host>
      </service>
    </services>
    <!-- A behavior definition for MEX -->
    <behaviors>
      <serviceBehaviors>
        <behavior name="SignalServiceMEXBehavior" >
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

  <connectionStrings>
    <clear />

  </connectionStrings>

</configuration>

I am not sure where I am wrong. 

我不知道为什么但是这个网站需要更多来自我的文字所以输入这一行,请忽略这个我不知道为什么但是这个网站需要更多来自我的文字所以输入这一行,请忽略这个我不要知道为什么,但这个网站需要更多的文字,所以输入这一行,请忽略这个我不知道为什么但这个网站需要更多的文字,所以输入这一行,请忽略这个我不知道为什么但这个网站我需要更多文字,所以输入这一行,请忽略此

1 个答案:

答案 0 :(得分:0)

这两个绑定非常不同。对于在不同地址公开的相同服务,您需要两个端点,并使用不同的绑定进行设置。

有关详细信息,请参阅此MSDN文章。

举个例子:

<service 
    name="Microsoft.ServiceModel.Samples.CalculatorService"
    behaviorConfiguration="CalculatorServiceBehavior">
  <!-- This endpoint is exposed at the base address provided by host:
       http://localhost/servicemodelsamples/service.svc  -->
  <endpoint address=""
            binding="basicHttpBinding"
            contract="Microsoft.ServiceModel.Samples.ICalculator" />
  <!-- secure endpoint exposed at {base address}/secure:
       http://localhost/servicemodelsamples/service.svc/secure -->
  <endpoint address="secure"
            binding="wsHttpBinding"
            contract="Microsoft.ServiceModel.Samples.ICalculator" />
  ...
</service>