Call the WCF service method from the web browser

advertisements

I want to run my service from the web browser: http://localhost:443/TestService//RunTest/data/test It doesn`t work for me

This page can’t be displayed

•Make sure the web address http://localhost:443 is correct.
•Look for the page with your search engine.
•Refresh the page in a few minutes.

How to solve that - redefine endpoint - how? The WCF service:

//TestService.svc.cs
public class TestService : ITestService
    {
        public string RunTest(string data)
        {
            return string.Format("You entered: {0}", data);
        }
}
//ITestService.cs
[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json, UriTemplate = "/RunTest/data/{data}")]
string RunTest(string data)
{
     return string.Format("You entered: {0}", proxyDomain);
}
//Web.config
<system.serviceModel>
    <services>
      <!-- This section is optional with the default configuration introduced
         in .NET Framework 4.5.1 -->
      <service
          name="TestService">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:443/TestService/"/>
          </baseAddresses>
        </host>
        <endpoint address="http://localhost:443/TestService"
                  binding="wsHttpBinding"
                  contract="ITestService" />
      </service>
    </services>
</system.serviceModel>

Also when I run it a WCF client is opened with port 54388


In my experience, you wouldn't be able to test directly via the browser. Instead you should use a WCF Test Client:

http://msdn.microsoft.com/en-us/library/bb552364(v=vs.110).aspx

What you can do using your browser, is to see if you can reach the WSDL. An example of a WSDL call in a browser:

http://localhost:8080/DecisionService/ws/PreTradeChecksRuleApp/1.0/PreTradeChecks/1.0?WSDL