简体   繁体   中英

WCF Service Metadata Exchange over TCP

I created a WCF Service hosted on IIS. With HTTP binding everything ist working fine. But when I switch to TCP binding it doesn't work any more. I tried every hint I found on the web, but no success.

Already done:

  • installed Windows-Feature "WCF-Non-Http-Activation"
  • activated Windows Service Net.Tcp-Listener Adapter

In WcfTestClient the service can't be added. But maybe this tool doesn't support TCP(?) so I also tested in Visual Studio by trying to add a service reference. Error Message when trying to add the service in VS:

An error occurred while attempting to find services at 'net.tcp://hostname:19099/Namespace/Company.Service.svc/mex'. No IPEndpoints were found for host hostname. Details: Metadata contains a reference that cannot be resolved: 'net.tcp://hostname:19099/Namespace/Company.Service.svc/mex'.

This is my current web.config (anonymized) - what am I doing wrong?

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.web>
        <compilation targetFramework="4.8"/>
        <httpRuntime targetFramework="4.8"/>
        <customErrors mode="Off"/>
    </system.web>
    
    <system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior name="ServiceBehavior">
                    <serviceMetadata />
                    <serviceDebug includeExceptionDetailInFaults="true"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>

        <services>
            <service name="Company.Namespace.Service" behaviorConfiguration="ServiceBehavior">
                <endpoint name="ServiceEndpoint" address="" binding="netTcpBinding"
                    bindingConfiguration="ServiceNetTcpBinding" contract="Company.Namespace.IService"/>
                <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
                <host>
            <baseAddresses>
                        <add baseAddress="net.tcp://hostname:19099/Namespace/Company.Service/"/>
            </baseAddresses>
        </host>
            </service>
        </services>

        <bindings>
            <basicHttpBinding>
                <binding name="ServiceBasicHttpBinding" sendTimeout="00:01:00" receiveTimeout="00:01:00" openTimeout="00:01:00" closeTimeout="00:01:00"/>
            </basicHttpBinding>
            <netTcpBinding>
                <binding name="ServiceNetTcpBinding" sendTimeout="00:01:00" receiveTimeout="00:01:00" openTimeout="00:01:00" closeTimeout="00:01:00"
                    transferMode="Buffered" transactionFlow="false" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288"
                    maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536" portSharingEnabled="false" transactionProtocol="OleTransactions">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
                    <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
                    <security mode="Transport">
                        <message clientCredentialType="None"/>
                        <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"/>
                    </security>
                </binding>
            </netTcpBinding>
            <wsHttpBinding>
                <binding name="ServiceWsHttpBinding" sendTimeout="01:00:30" receiveTimeout="01:00:30"/>
            </wsHttpBinding>
        </bindings>

        <protocolMapping>
            <add binding="basicHttpsBinding" scheme="https"/>
        </protocolMapping>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>

    </system.serviceModel>

    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
        <directoryBrowse enabled="true"/>
    </system.webServer>
</configuration>

When you say that you cancel the maximum number of connections and it works, does that mean that the maximum number of connections limits your network?

As far as I know, IIS 5/6 does not support non-HTTP services. IIS7 supports Net TCP, but you must install WAS first. Refer to the following steps:

  1. Control Panel -- Programs and Features -- Turn Windows features on or off and install WAS.
  2. Check whether non-HTTP support is enabled for WCF. Select the same interface in .NET Framework.
  3. Add the Net TCP binding to the site and enable the Net TCP protocol.

Further details can also be found in this docs .

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