none
Adding different bindings in WCF Service RRS feed

  • Question

  • How to add net.tcp,https,basichttp bindings to wcf service web.config file.If I debug the  sevice  I need the url like example given below

    eg :         net.tcp://  localhost/WCFservice1

    this is my web.config file

    <?xml version="1.0"?>
    <configuration>

      <system.web>
        <compilation debug="true" targetFramework="4.0" />
      </system.web>
      <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="NewBinding2" />
          </basicHttpBinding>
          <netTcpBinding>
            <binding name="NewBinding0" />
          </netTcpBinding>
          <wsDualHttpBinding>
            <binding name="NewBinding1" />
          </wsDualHttpBinding>
        </bindings>
        <services>
          <service name="WCFEMRService">
            <endpoint address="" binding="netTcpBinding"
              bindingConfiguration="NewBinding0" contract="WCFEMRService.IService1">
            </endpoint>
            <endpoint address="" binding="wsDualHttpBinding"
              bindingConfiguration="NewBinding1" contract="WCFEMRService.IService1" />
            <endpoint address="" binding="basicHttpBinding"
              bindingConfiguration="NewBinding2" contract="WCFEMRService.IService1" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
              <serviceMetadata httpGetEnabled="true" />
              <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
      </system.webServer>

    </configuration>

    It's working fine.But I want net.tcp,or https ... enabled and accessible..

    please help....

     
    Tuesday, January 15, 2013 6:55 PM

Answers

  • Hi,

    >>The message could not be dispatched because the service at the endpoint address 'net.tcp://iibcdsk029/WCF/Service1.svc' is unavailable for the protocol of the address.

    The issue may caused by your address setting for netTcpBinding.

    Below is test code from my side that configured both basicHttpBinding and netTcpBinding.

    <configuration>
    
      <system.web>
        <compilation debug="true" />
      </system.web>
      <system.serviceModel>
        <services>
          <service name="WcfServiceLibrary1.Service1" behaviorConfiguration="WcfServiceLibrary1.Service1Behavior">
            <host>
              <baseAddresses>
                <add baseAddress = "http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary1/Service1/" />
                <add baseAddress = "net.tcp://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/" />          
              </baseAddresses>
            </host>
    
            <!-- endpoint 1: Basic HTTP -->
            <endpoint address="basicHelloWorldService"
                      binding="basicHttpBinding" name="httpEndpoint"
                      contract="WcfServiceLibrary1.IService1" />
            <!-- endpoint 2: TCP -->
            <endpoint address="nettcpHelloWorldService"
                      binding="netTcpBinding" bindingConfiguration="" name="tcpEndpoint"
                      contract="WcfServiceLibrary1.IService1" />
       
            <!-- Metadata Endpoints -->
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="WcfServiceLibrary1.Service1Behavior">
              <serviceMetadata/>
              <serviceDebug includeExceptionDetailInFaults="False" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
    
    </configuration>

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, January 17, 2013 6:15 AM
    Moderator

All replies

  • You just need to add multiple base addresses for the service.

    <host>

    <baseAddresses>

    <addbaseAddress="net.tcp://localhost/WCFservice1"/>

    <addbaseAddress="https://localhost/WCFservice1"/>

    </baseAddresses>

    </host>

    • Proposed as answer by bryanfree66 Tuesday, January 15, 2013 7:58 PM
    Tuesday, January 15, 2013 7:16 PM
  • I have added the config. file with address and binding as well...

    but when i consume the address in Client with net.tcp endpoint ...

    its create a different address with same end point ...

    when I runs my application it shows the error

    The message could not be dispatched because the service at the endpoint address 'net.tcp://iibcdsk029/WCF/Service1.svc' is unavailable for the protocol of the address.

    My App.Confg file :-

    <?

    xml version="1.0" encoding="utf-8" ?>

    <

    configuration>

    <

    system.serviceModel>

    <

    bindings>

    <

    basicHttpBinding>

    <

    binding name="BasicHttpBinding_IService1" closeTimeout="00:01:00"

    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"

    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"

    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"

    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"

    useDefaultWebProxy="true">

    <

    readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"

    maxBytesPerRead="4096" maxNameTableCharCount="16384" />

    <

    security mode="None">

    <

    transport clientCredentialType="None" proxyCredentialType="None"

    realm="" />

    <

    message clientCredentialType="UserName" algorithmSuite="Default" />

    </

    security>

    </

    binding>

    </

    basicHttpBinding>

    <

    netTcpBinding>

    <

    binding name="NetTcpBinding_IService1" closeTimeout="00:01:00"

    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"

    transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"

    hostNameComparisonMode="StrongWildcard" listenBacklog="10"

    maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"

    maxReceivedMessageSize="65536">

    <

    readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"

    maxBytesPerRead="4096" maxNameTableCharCount="16384" />

    <

    reliableSession ordered="true" inactivityTimeout="00:10:00"

    enabled="false" />

    <

    security mode="Transport">

    <

    transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />

    <

    message clientCredentialType="Windows" />

    </

    security>

    </

    binding>

    </

    netTcpBinding>

    </

    bindings>

    <

    client>

    <

    endpoint address="http://localhost/WCF/Service1.svc" binding="basicHttpBinding"

    bindingConfiguration="BasicHttpBinding_IService1" contract="WCFEMRService.IService1"

    name="BasicHttpBinding_IService1" />

    <

    endpoint address="net.tcp://iibcdsk029/WCF/Service1.svc" binding="netTcpBinding"

    bindingConfiguration="NetTcpBinding_IService1" contract="WCFEMRService.IService1"

    name="NetTcpBinding_IService1">

    <

    identity>

    <

    servicePrincipalName value="host/IIBCDSK029" />

    </

    identity>

    </

    endpoint>

    </

    client>

    </

    system.serviceModel>

    </

    configuration>

    Wednesday, January 16, 2013 8:54 AM
  • Hi,

    >>The message could not be dispatched because the service at the endpoint address 'net.tcp://iibcdsk029/WCF/Service1.svc' is unavailable for the protocol of the address.

    The issue may caused by your address setting for netTcpBinding.

    Below is test code from my side that configured both basicHttpBinding and netTcpBinding.

    <configuration>
    
      <system.web>
        <compilation debug="true" />
      </system.web>
      <system.serviceModel>
        <services>
          <service name="WcfServiceLibrary1.Service1" behaviorConfiguration="WcfServiceLibrary1.Service1Behavior">
            <host>
              <baseAddresses>
                <add baseAddress = "http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary1/Service1/" />
                <add baseAddress = "net.tcp://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/" />          
              </baseAddresses>
            </host>
    
            <!-- endpoint 1: Basic HTTP -->
            <endpoint address="basicHelloWorldService"
                      binding="basicHttpBinding" name="httpEndpoint"
                      contract="WcfServiceLibrary1.IService1" />
            <!-- endpoint 2: TCP -->
            <endpoint address="nettcpHelloWorldService"
                      binding="netTcpBinding" bindingConfiguration="" name="tcpEndpoint"
                      contract="WcfServiceLibrary1.IService1" />
       
            <!-- Metadata Endpoints -->
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="WcfServiceLibrary1.Service1Behavior">
              <serviceMetadata/>
              <serviceDebug includeExceptionDetailInFaults="False" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
    
    </configuration>

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, January 17, 2013 6:15 AM
    Moderator