2
votes

This is a follow on from this question I've configured the a WCF service running in IIS (From within Visual Studio 2010) to run one Web service and one net.tcp service. After a lot of hacking I've managed to get the Web Service to load into the WCF test client, but I can't get the Net.Tcp service to load into the test client.

Here is my Web.config:

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

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="ServerService" behaviorConfiguration="ServerServiceBehaviour">
        <endpoint address="ServerService.svc" 
                  binding="netTcpBinding" 
                  bindingConfiguration="DefaultNetTcpBindingConfig" 
                  name="NetTcpEndPoint" 
                  contract="IServerService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>

        <endpoint address="mex"
                  binding="mexTcpBinding"
                  contract="IMetadataExchange" 
                  bindingConfiguration="mexTcpBinding"/>
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:8523/"/>
          </baseAddresses>
        </host>
      </service>

      <service name="MyWebService" behaviorConfiguration="WebServiceBehaviour">
        <endpoint address="MyWebService.svc"
                  binding="wsHttpBinding"
                  bindingConfiguration="DefaultWSBinding"
                  name="MyWSEndPoint"
                  contract="IMyWebService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex"
                  binding="mexHttpBinding"
                  contract="IMetadataExchange"
                  bindingConfiguration="mexHttpBinding"/>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8523/"/>
          </baseAddresses>
        </host>
      </service>

    </services>
    <bindings>
      <netTcpBinding>
        <binding name="DefaultNetTcpBindingConfig"
                 maxConnections="5"
                 portSharingEnabled="true" >
        </binding>
        <!--<binding name="mexBinding"
                 portSharingEnabled="true">
          <security mode="None"></security>
        </binding>-->
      </netTcpBinding>
      <wsHttpBinding>
        <binding name="DefaultWSBinding"/>
      </wsHttpBinding>
      <mexTcpBinding>
        <binding name="mexTcpBinding"/>
      </mexTcpBinding>
      <mexHttpBinding>
        <binding name="mexHttpBinding"/>
      </mexHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServerServiceBehaviour">
          <!-- 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>
        <behavior name="MexBehaviour">
          <serviceMetadata httpGetEnabled="true" policyVersion="Policy15"/>
        </behavior>
        <behavior name="WebServiceBehaviour">
          <!-- 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>

When I run the Visual Studio Debugger to publish the Service I can access the web service by entering the following url into the WCF Test Application:

http://localhost:8523/MyWebService.svc

But if I enter the following Url into the WCF Test Application I get an error:

net.tcp://localhost:8523/ServerService.svc

Here is the Error I see:

Error: Cannot obtain Metadata from net.tcp://localhost:8523/ServerService.svc If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: net.tcp://localhost:8523/ServerService.svc Metadata contains a reference that cannot be resolved: 'net.tcp://localhost:8523/ServerService.svc'. You have tried to create a channel to a service that does not support .Net Framing. It is possible that you are encountering an HTTP endpoint. Expected record type 'PreambleAck', found '72'.

Having read this question is it possible that the webserver in VS 2010 doesn't support net.tcp binding?

1
I think the issue might be that the Web Server built into Visual Studio 2010 doesn't support Net.Tct Binding I'm installing IIS and I'm going to tell it to use that instead.Omar Kooheji

1 Answers

0
votes

It looks like the issue I was seeing was that the Web Server in Visual Studio 2010 doesn't support Net.Tcp Binding.

I've got slightly further by installing IIS7 (IIS6 doesn't support Net.Tcp either) and telling visual studio to use IIS instead.

You can do this by going to the properties page of your service and selecting the "Web Tab" select the Use Local IIS Web Server radio Button and configure the webserver.

You can also tell is to start an external program on this tab to make it start the WcfTestClient.exe and pass in the URL to your services as command line parameters.

I'm still having issues but they are different issues so I'll open another question.