Search code examples
wcfnettcpbinding

Service Reference Error - netTcpBinding


I was working on WCF service with an endpoint binding of netTcpBinding, hosted in a console application.

These are the configuration settings:

<system.serviceModel>  
    <services>  
        <service name="FullTimePartTime_EmpWCFServiceAppl.EmployeeService" 
                 behaviorConfiguration="mexBehaviour" >  
            <endpoint 
                address="EmployeeService" 
                binding="netTcpBinding" 
                contract="FullTimePartTime_EmpWCFServiceAppl.IEmployeeService">  
            </endpoint>  
            <endpoint 
                address="mex" 
                binding="mexTcpBinding" 
                contract="IMetadataExchange">  
            </endpoint>  
            <host>  
                <baseAddresses>  
                    <add baseAddress="net.tcp://localhost:7090/"/>  
                </baseAddresses>  
            </host>  
        </service>  
    </services>  
    <behaviors>  
        <serviceBehaviors>  
            <behavior name="mexBehaviour">  
                <serviceMetadata httpGetEnabled="false" />  
            </behavior>  
        </serviceBehaviors>  
    </behaviors>  
</system.serviceModel>

The console application executes fine. WPF is client app which should consume the WCF service, but when I tried to add a service reference, this error occurred:

Service Reference Error

Can anyone help me to fix this issue & let me know the mistake I made?

Thanks in advance.


Solution

  • Always the metadata discovery is through http.So you need to have one more base address for the http which publishes the metdata via http.

     <host>  
      <baseAddresses>  
     <add baseAddress="http://localhost:7091/"/>  
      <add baseAddress="net.tcp://localhost:7090/"/>  
      </baseAddresses>  
     </host>  
    

    First try to browse the metadata through http://localhost:7091/?wsdl. Now try to generate proxy class using the service reference address http://localhost:7091/.