John
John

Reputation: 487

Calling a WCF service endpoint

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>

Upvotes: 2

Views: 6336

Answers (4)

Andrey Marchuk
Andrey Marchuk

Reputation: 13483

You can do it from the browser only if you are using webHttpBinding. What you could do is use WcfTestClient tool it's located here: "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\WcfTestClient.exe"

Also, your metadata is disabled, so in order to use WcfTestClient you will need to set httpGetEnabled to true in your webservice app.config

Upvotes: 0

Rajesh
Rajesh

Reputation: 7876

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>

Upvotes: 3

Roy Dictus
Roy Dictus

Reputation: 33139

Why don't you just enable Service Metadata generation? Once you have that, you can just right-click on your service in Visual Studio and select "Browse...". VS will then open your browser to the right URL, and you can click the name of the method you want to execute. Then you'll see the correct URL to call your method, provided that HTTP GET is enabled (so you're not using SOAP).

Otherwise, you'll have to use a WCF test environment such WCF Storm: http://www.wcfstorm.com/wcf/home.aspx

Upvotes: 1

lnu
lnu

Reputation: 1414

The best is wcf storm. It's really powerful when it comes to test wcf.

Upvotes: 0

Related Questions