1

I just developed a WCF service that I was calling with AngularJS. After a while, I noticed that I needed the user to authenticate himself with its windows credentials. Therefore, I turned "windows authentication" mode on and "anonymous authentication" off. When I call my service in the browse, I'm prompted to log myself in but when I do I get a blank response. When I check the status of it, I get a 400. Here is my web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.web>
    ...
    <authentication mode="Windows" />
    <authorization>
      <deny users="?"/>
    </authorization>
  </system.web>
  <system.webServer>
    ...
  </system.webServer>
  <system.serviceModel>

    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpEndpointBinding">
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Windows" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />

    <services>      
      <service name="TeamCity.WebServices.ConfigurationService">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpEndpointBinding" contract="TeamCity.Interfaces.IConfigurationService" />
      </service>
    </services>
  </system.serviceModel>
</configuration>

Does anyone have an idea ?

ssougnez
  • 4,202
  • 9
  • 36
  • 65
  • Does it make any difference if you add a to the element after the element? – idream1nC0de Feb 04 '16 at 16:38
  • Nop. However, I just edited my original message because the error code that I receive is "400: Bad Request", and not "401". When I tried to attach the debugger to my web service, it does not even reach the method it's supposed to reach... – ssougnez Feb 04 '16 at 17:02
  • 1
    You can't use basicHttpBinding with RESTful WCF. You need to use webHttpBinding. basicHttpBinding works well with transmitting SOAP messages, but when communicating over REST, you have to expose the endpoint using webHttpBinding. https://msdn.microsoft.com/en-us/library/bb412176(v=vs.110).aspx – idream1nC0de Feb 04 '16 at 17:06
  • Here is more information on binding configurations for REST with WCF. http://stackoverflow.com/questions/186631/rest-soap-endpoints-for-a-wcf-service Also, it may be helpful to show how you're calling the service from the client. – idream1nC0de Feb 04 '16 at 17:08
  • I just changed the binding to "webHttpBinding", added the endPointBehavior "webHttp" and it works for GET method. However, when I try to do a PUT, a popup of identification is shown and if I enter my credentials, it keeps on poping. However, I configured my "$httpProvider" this way: "$hp.defaults.withCredentials = true;". – ssougnez Feb 04 '16 at 22:58
  • It would greatly help troubleshooting to see your JavaScript in the question. Could you please update the post? – idream1nC0de Feb 05 '16 at 01:21
  • Hi, I just found the issue. The user needed write permission on the svc file. Thanks – ssougnez Feb 05 '16 at 13:13
  • Great! Glad to hear that the issue is resolved! – idream1nC0de Feb 05 '16 at 15:01

0 Answers0