ANo
ANo

Reputation:

Deploy WCF service, C#, WCF, VS2008

I have a test project, WCF Service Library, and I published the project. Have a 2003 server with all the right installation. I browse to my application and upon clicking on .svc I get this error.

The type 'SearchService', provided as the Service attribute value in the ServiceHost directive could not be found.

This is the snippet from my web.config

<endpoint address="" binding="wsHttpBinding" contract="TestService.ISearchService">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>

My Interface:

  [ServiceContract]
public interface ISearchService
{
    [OperationContract]
    string GetName();
}

My Implementation:

   [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerSession)]
public class SearchService :ISearchService
{
    #region ISearchService Members

    public string GetName()
    {
      returnn "HAL-2001" 
    }

 }

Upvotes: 0

Views: 963

Answers (4)

Hongwei Yan
Hongwei Yan

Reputation: 498

ANo, the error indicates the host could not find the definition for service implementation "SearchService" in your web.config. In you web.config, you need to wrap the <endpoint> tag in a <service> tag. The name attribute of the <service> should be set to the full name of you SearchService class ( including all namespaces). You also need to define a behavior to enable the service to show WSDL in a browser. You may also want to remove the <dns value="localhost" /> when you deploy the service to a server.

Here is an example snippet, make sure your put the full class name of SearchService in <service> tag, and also make sure the full class name is in your .svc file:

<system.serviceModel>
 <services>
  <service name="SearchService" behaviorConfiguration="ServiceBehavior">
    <endpoint address="" binding="wsHttpBinding" contract="TestService.ISearchService">
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior">
      <!-- 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>  </system.serviceModel>

Upvotes: 2

Joshua Belden
Joshua Belden

Reputation: 10503

ANo, you should switch over to the basicHttpBinding and test to make sure everything is working. You're using the WSHttpBinding and by default it has authentication turned on. You're client will need to pass credentials for it to actually get a response, that's why the browser call isn't working.

Upvotes: 1

marc_s
marc_s

Reputation: 754200

Well, the wsHttpBinding requires you to connect to your service using SOAP - a web browser alone won't cut it, so that's why it's not working when you browse to the .svc file. Nothing wrong there, really.

You need to create a real full-fledged SOAP client to connect to your service and test it. Alternatively, you could also use the WcfTestClient.exe test client which sits in your VS2008\Common7\IDE folder.

Marc

Upvotes: 2

Antonio Haley
Antonio Haley

Reputation: 4790

What is your client code calling? For this to work it should be calling a proxy class like the following.

class SearchServiceProxy : ClientBase<ISearchService>, ISearchService
{
    public string GetName()
    {
        return Channel.GetName();
    }
}

Upvotes: 0

Related Questions