C# – Calling a WCF service endpoint

cwcfweb services

I have created a WCF service with an endpoint, hosted in IIS, with a .svc file. When I hit the endpoint I get:

enter image description here

So it look like the end point is up.

I have created a Service Contract

[ServiceContract]
public interface ImyService
{
   [OperationContract]
   String GetSearchResults();
}

And created a class

[AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed)]
public class myService : ImyService
{
    public String GetSearchResults()
    {
        return "Hello World";
    }
}

How do I call the GetSearchResults method in the browser?

Edit

The binding is:

<bindings>
  <basicHttpBinding>
    <binding name="customBasicHttpBinding">
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Ntlm"/>
      </security>
    </binding>
  </basicHttpBinding>
</bindings>

Best Answer

You cannot test the result of the WCF service in browser. You can test it using the WCF Test client. In your IDE just open your .svc or .svc.cs file and then click F5 which should launch the WCF Test client.

NOTE: Your project type is WCF Service Application Project

Also set the below in your web.config to enable metadata exchange.

<serviceBehaviors>
    <behavior>
    <serviceMetadata httpGetEnabled="true"/>
    <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
</serviceBehaviors>
Related Topic