0

I have a sample project for a ReST service in WCF. And I am just trying to debug it. When I start the debugging however, the service always starts inside "WCF Test Client" tool. Instead, I am looking for the host to run inside the browser, so that I can download WSDL file.

I have tried removing the "Start options" in the project properties. Then instead of WCF Test Client, service opens in WCF Self Host. If I try to use postman to call the service with WCF Self Host enabled, then execution never reaches the code, and just throws 400 error code.

I also tried attaching the debugger to Chrome, and that did nothing. I have no idea what I am missing in the configuration or Visual studio options. I am expecting that when I start the debugging, it opens a new tab in the browser with the base address of the service.

Below is my current config file.

  <system.web>
<compilation debug="true" />
<membership defaultProvider="ClientAuthenticationMembershipProvider">
  <providers>
    <add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
  </providers>
</membership>
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
  <providers>
    <add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
  </providers>
</roleManager>
</system.web>
 <system.serviceModel>
<services>
  <service name="WellacyMobileAPI.Service">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8733/WellacyMobileAPI/" />
      </baseAddresses>
    </host>
    <endpoint address="" binding="basicHttpBinding" contract="WellacyMobileAPI.IService">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
  </service>
</services>
<behaviors>
  <endpointBehaviors>
    <behavior name="serviceBehavior">
      <webHttp />
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="serviceBehavior">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <serviceAuthorization serviceAuthorizationManagerType="WellacyMobileAPI.RestAuthorizationManager, WellacyMobileAPI" />
    </behavior>
    <behavior name="">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
 </system.serviceModel>
jitendragarg
  • 945
  • 1
  • 14
  • 54

1 Answers1

1

The reason why the WCF test client is started by default when debugging the WCF Service is that the browser doesn’t support SOAP message. it means that not all WCF services are http-mode WCF service, so that the browser could not trigger the other WCF service, which communicates with the client via the other binding and message format.
https://learn.microsoft.com/en-us/dotnet/framework/wcf/wcf-and-aspnet-web-api

Abraham Qian
  • 7,117
  • 1
  • 8
  • 22
  • Ok. So, that means somewhere in my config file, there is configuration for SOAP? Wait, let me add the config file into the question. – jitendragarg Nov 20 '18 at 09:25
  • 1
    you want to publish the service as a restful service? you should change the basichttpbinding to webhttpbinding and apply the webhttp behavior to the endpoint.https://stackoverflow.com/questions/53200663/how-can-i-use-a-wcf-service/53203436#53203436 – Abraham Qian Nov 21 '18 at 03:24
  • Awesome. Thanks. It was the problem. I had the binding created as webhttp, but didn't change that in the actual endpoint. – jitendragarg Nov 21 '18 at 06:25