0

I have an existing WCF service which does not have *.SVC file. The project itself is website and WCF code is written in it. It is using this line for registering service:

RouteTable.Routes.Add(new ServiceRoute("", new WebServiceHostFactory(), typeof(Service1)));

I run the project from Visual Studio and check from IE that the service is hosted and working by testing following method:

http://localhost:51838/GetBenchMark/20

I have to create a console app which makes use of this WCF service. When I try to use "Add Service Reference" from Visual studio and give the path http://localhost:51838/, it is not able to find it and gives error:

    The HTML document does not contain Web service discovery information.
Metadata contains a reference that cannot be resolved: 'http://localhost:51838/'.
There was no endpoint listening at http://localhost:51838/ that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
The remote server returned an error: (404) Not Found.
If the service is defined in the current solution, try building the solution and adding the service reference again.

This is web.config if it helps:

 <system.web>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
  </system.web>
  <system.web.extensions>
    <scripting>
      <webServices>
        <jsonSerialization maxJsonLength="2147483647" />
      </webServices>
    </scripting>
  </system.web.extensions>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true">
      <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </modules>
  </system.webServer>
  <system.serviceModel>
    <client />
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    <standardEndpoints>
      <webHttpEndpoint>
        <!-- 
            Configure the WCF REST service base address via the global.asax.cs file and the default endpoint
            via the attributes on the <standardEndpoint> element below
        -->
        <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" />
      </webHttpEndpoint>
    </standardEndpoints>
    <bindings>
      <webHttpBinding>
        <binding closeTimeout="00:20:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" transferMode="Buffered" useDefaultWebProxy="true">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </binding>
      </webHttpBinding>
    </bindings>
  </system.serviceModel>

Please let me know what should I do to generate proxy classes and start using this service from console app.

CleanBold
  • 1,551
  • 1
  • 14
  • 37
  • IS there a MEX endpoint exposed? See: http://stackoverflow.com/questions/7285717/why-do-i-need-both-mex-endpoint-and-httpgetenable – Preet Sangha Nov 21 '13 at 08:05
  • Don't know what MEX is but I don't think that is exposed – CleanBold Nov 21 '13 at 08:43
  • You need the metadata to allow applications to work out the econtracts for your service - one such application is the Service Proxy creator in VS. Read this: http://blogs.microsoft.co.il/idof/2011/08/10/wsdl-vs-mex-knockout-or-tie/ – Preet Sangha Nov 21 '13 at 09:04

1 Answers1

0

If you create a WCF-Service, you have to create a Host-Application, you can not start this WCF-Library on its own.

If you want to start your WCF-Service seperate from a Host-Application, create a WCF-Application. There you have a svc and you can start it like you describe it in your question.

Obl Tobl
  • 5,604
  • 8
  • 41
  • 65
  • The project is website project and WCF code is written within the project. Hence, I am able to run/debug it from visual studio. – CleanBold Nov 21 '13 at 08:48