locked
Consume WCF hosted in a Windows Service from a ASP.NET application RRS feed

  • Question

  • User-2066177896 posted

    Hi,

    I created a WCF service and hosted it in a Windows Service. I installed the windows Service using InstallUtil on my local PC.

    If i have to comnsume it from a web application how do iadd the reference? How can i consume this service?

    EDIT:

    When i try to add service reference :   net.tcp://localhost:8731/Design_Time_Addresses/WCFJobsLibrary/Jobs

    I get the following errors:

    Metadata contains a reference that cannot be resolved: 'net.tcp://localhost:8731/Design_Time_Addresses/WCFJobsLibrary/Jobs/'.
    Could not connect to net.tcp://localhost:8731/Design_Time_Addresses/WCFJobsLibrary/Jobs/. The connection attempt lasted for a time span of 00:00:02.0010000. TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:8731.
    No connection could be made because the target machine actively refused it 127.0.0.1:8731
    If the service is defined in the current solution, try building the solution and adding the service reference again.

    Thanks

    <system.serviceModel>
        <services>
          <service behaviorConfiguration="WCFJobsLibrary.JobsBehavior"
            name="WCFJobsLibrary.Jobs">
            <endpoint address="" binding="netTcpBinding" bindingConfiguration=""
              contract="WCFJobsLibrary.IJobs">
              <identity>
                <dns value="localhost" />
              </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            <host>
              <baseAddresses>
                <add baseAddress="net.tcp://localhost:8731/Design_Time_Addresses/WCFJobsLibrary/Jobs/" />
              </baseAddresses>
            </host>
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="WCFJobsLibrary.JobsBehavior">
              <serviceMetadata httpGetEnabled="false" />
              <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>


    Friday, October 18, 2013 9:37 AM

Answers

  • User503812343 posted

    you are using mexHttpBinding, for netTcpBinding you have to use mexTcpBinding. Make sure you install your Windows Service with Administrative rights.

    for more details on hosting wcf service in windows service

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 18, 2013 11:17 AM