简体   繁体   English

如何将netTcpBinding和netMsmqBinding一起使用?

[英]How to use netTcpBinding and netMsmqBinding together?

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. 

I don't know why but this site needs more text from me so typing this line, please ignore this I don't know why but this site needs more text from me so typing this line, please ignore this I don't know why but this site needs more text from me so typing this line, please ignore this I don't know why but this site needs more text from me so typing this line, please ignore this I don't know why but this site needs more text from me so typing this line, please ignore this 我不知道为什么,但是此站点需要我提供更多文本,因此请键入此行,请忽略此内容。我不知道为什么,但是此站点需要我获得更多文本,因此请键入此行,请忽略此信息,我不知道为什么但是此站点需要我发送更多文本,因此请键入此行,请忽略此行,我不知道为什么,但此站点需要我发送更多行,请忽略此消息,我不知道为什么,但此站点需要更多文本从我这里输入,请忽略此行

Those two bindings are very different. 这两个绑定非常不同。 You need two endpoints for the same service exposed at different addresses and set up with different bindings. 对于同一服务,您需要两个端点在不同的地址公开并设置不同的绑定。

See this MSDN article for more information on this. 有关更多信息,请参见此MSDN文章。

As an example: 举个例子:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM