0

Want to enable https on my REST JSON WCF service and test it in IE browser. WSDL is loading with no issues (https://localhost/myservice/Imyservice.svc?WSDL). But i tried to call a operation ( https://localhost/myservice/Imyservice.svc/Getdata), I am getting Request Error The server encountered an error processing the request. . Below is my web.config. Can anyone help me with this

  <webHttpBinding>
    <binding name="SecureBasicRest" allowCookies="true" >
      <security mode="Transport" />
      <readerQuotas maxDepth="32"/>
    </binding>
  </webHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="svcBehavior">
      <serviceMetadata httpsGetEnabled="true" httpGetEnabled="false"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="svcEndpoint">
      <webHttp helpEnabled="true"/>
    </behavior>
  </endpointBehaviors>

</behaviors>
<services>
  <service name="myservice.Imyservice" behaviorConfiguration="svcBehavior">
    <endpoint binding="webHttpBinding" bindingConfiguration="SecureBasicRest"
              behaviorConfiguration="svcEndpoint" name="webHttp"
              contract="myservice.Imyservice" />
  </service>

</services>


<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

1 Answers1

0

The root cause is that there is something wrong with the definition of the service endpoint.

<service name="myservice.Imyservice" behaviorConfiguration="svcBehavior">
    <endpoint binding="webHttpBinding" bindingConfiguration="SecureBasicRest"
              behaviorConfiguration="svcEndpoint" name="webHttp"
              contract="myservice.Imyservice" />
  </service>

Your idea is correct, we should add a service endpoint with transport security mode. However, the service name should be a fully qualified name of the service implemented class instead of the service interface.

<service name="myservice.myservice"

Feel free to let me know if the problem still exists.

Abraham Qian
  • 7,117
  • 1
  • 8
  • 22
  • @user3747239 , Please pay attention to the service URL since we didn’t define the Address attribute in the service endpoint. The service Url should be, https://localhost/myservice.svc/GetData In the MyService.cs file, we are supposed to have a service class implemented IService interface. – Abraham Qian May 13 '20 at 07:42
  • Here is an example. https://stackoverflow.com/questions/53761119/wcf-service-not-hitting-from-postman-over-https/53776265#53776265 – Abraham Qian May 13 '20 at 07:42