简体   繁体   中英

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.

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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