tags:

views:

161

answers:

3

I get "Endpoint not found" when attempting to access my service via the browser at

http://localhost:10093/Services/Service1.svc

I get "Error: Cannot obtain Metadata from http://localhost:10093/Services/Service1.svc" when attempting to access the same address from the wcftestclient.

If I place a breakpoint in the service implementation it is hit, so I assume the svc file is setup correctly:

<%@ ServiceHost Language="C#" Debug="true" 
Service="MyApp.Core.Service.Service.MyAppService,MyApp.Core.Service" 
Factory="CommonServiceFactory.WebServiceHostFactory,CommonServiceFactory" %>

Here is my config:

<system.serviceModel>
    <services>
      <service name="MyApp.Core.Service.Service.MyAppService,MyApp.Core.Service"
               behaviorConfiguration="MainServiceBehavior">
        <endpoint name="newEndpoing" 
             binding="basicHttpBinding" bindingConfiguration=""
             contract="MyApp.Core.Service.IMyAppService" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MainServiceBehavior">
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
+2  A: 

So you have a *.svc file to host your service. Can you right-click in Visual Studio on that file and say "Show in Browser" ? Do you get anything there, or does it throw an error right away??

Next: your service endpoint has no address="" attribute, which I believe is mandatory - try adding that (even if you don't specify an address in it).

If you're hosting in IIS, your service address is defined by the virtual directory where your SVC file is present, and the SVC file itself - you might not be able to define a specific port or anything (IIS will handle that).

So try to connect to

http://localhost/Services/Service1.svc

Does that work by any chance??

Update: reading your post again more closely, you're specifying a special factory for the service - WebServiceHostFactory. Is this the default WebServiceHostFactory provided by .NET, or is that something you built yourself??

The point is: the .NET WebServiceHostFactory will use the webHttpBinding for RESTful WCF services - that won't work with an endpoint specifying basicHttpBinding, nor will the REST service have any metadata....

Update #2: try to use just the service's fully qualified class name, but without the assembly specification, in both your SVC file, and the config file.

So change this:

Service="MyApp.Core.Service.Service.MyAppService,MyApp.Core.Service" 

to this:

Service="MyApp.Core.Service.Service.MyAppService" 

SVC file:

<%@ ServiceHost Language="C#" Debug="true" 
Service="MyApp.Core.Service.Service.MyAppService" %>

Config file:

<services>
  <service name="MyApp.Core.Service.Service.MyAppService"
           behaviorConfiguration="MainServiceBehavior">
     <endpoint name="newEndpoing" 
          binding="basicHttpBinding" bindingConfiguration=""
          contract="MyApp.Core.Service.IMyAppService" />
  </service>
</services>
marc_s
Yes, I'm using a .svc to host the service. I get the same when I right click and view in browser.
chief7
Added empty address, no change.Tried url without port, recieved "Internet Explorer cannot display the webpage"It is a special factory but I tried using the standard host factory and got the same error
chief7
@Chief7: as long as you cannot do the "View in Browser" successfully, your service has a major problem and as long as that doesn't work, you won't be able to launch the service. Updated my answer with a few more recommendations to try out
marc_s
Tried removing the assembly name but got "Unable to create an instance of the requested service type."
chief7
@Chief7: OK, so in the SVC file, you probably need the class name plus the assembly. But in the regular config file, you definitely should have nothing but `<service name="MyApp.Core.Service.Service.MyAppService" ....` (no assembly reference there)
marc_s
Also, changed to use System.ServiceModel.Activation.WebServiceHostFactory and still got "Endpoint not found" in the browser.
chief7
Add assembly name back to svc, still get "Endpoint not found".
chief7
Here is a proof that exibists the same behavior, http://www.nippyzip.com/uploads/101003074000-57717.zip
chief7
A: 

Your error message is "Cannot obtain Metadata" and you do not have a MetadataExchange endpoint defined. You do have httpGetEnabled="True", which is also required.

Try defining a MEX endpoint, for details how to see: http://bloggingabout.net/blogs/dennis/archive/2006/11/09/WCF-Part-4-3A00-Make-your-service-visible-through-metadata.aspx

Shiraz Bhaiji
thanks for the answer but no change after adding a mex endpoint
chief7
A: 

Hello, my web.config for my WCF service is very similar to yours. You definitely have to add the MEX endpoint like Shiraz said. I've added a behavior configuration that lets any message size go through the WCF. Try to use these settings if it can help you (don't forget to change the contract settings):

<system.serviceModel>    
<diagnostics>
  <messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
</diagnostics>
<bindings>
  <basicHttpBinding>
    <binding name="BasicHttpBinding_IService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="524288000" maxBufferPoolSize="524288000" maxReceivedMessageSize="524288000" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
      <readerQuotas maxDepth="500000000" maxStringContentLength="500000000" maxArrayLength="500000000" maxBytesPerRead="500000000" maxNameTableCharCount="500000000" />
      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None" realm="">
          <extendedProtectionPolicy policyEnforcement="Never"/>
        </transport>
        <message clientCredentialType="UserName" algorithmSuite="Default"/>
      </security>
    </binding>
  </basicHttpBinding>
 </bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="serviceBehavior">
      <dataContractSerializer maxItemsInObjectGraph="6553600" />
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
  <service behaviorConfiguration="serviceBehavior" name="RC.Svc.Web.TPF.Service">
    <endpoint
       address=""
       binding="basicHttpBinding"
       bindingConfiguration="BasicHttpBinding_IService"
       contract="RC.Svc.Web.TPF.IService" />
    <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
  </service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<client />

Animal Mother
You can also use the WcfTestClient.exe in your Visual Studio folder to test that out easily (Visual Studio 10.0\Common7\IDE\WcfTestClient.exe and http://msdn.microsoft.com/en-us/library/bb552364.aspx). You'll need a working MEX endpoint.
Animal Mother
I have a mex point defined and tried adding the service to the wcftestclient. I says the service was added successfully but no services are added to the list.
chief7