WCF gives an unsecured or incorrectly secured fault error

前端 未结 21 2540
予麋鹿
予麋鹿 2020-11-28 23:09

I am trying to consume a remote svc web service. I created the proxy class using svcutil.exe, and after that I\'ve added that class to my console application, b

21条回答
  •  醉话见心
    2020-11-28 23:38

    Although your problem was solved with one of the above solutions, for the benefit of others, here's another option.

    You also can get this exception when incorrect credentials are passed to a basic endpoint (SOAP 1.1) that uses username message credentials as you are. For example, if you are calling the service from code and do something like this:

    var service = new TestService();
    
    service.ClientCredentials.UserName.UserName = "InvalidUser";
    service.ClientCredentials.UserName.Password = "InvalidPass";
    

    This is different from a WSHTTP endpoint (SOAP 1.2) that throws an AccessDeniedException when invalid credentials are passed through. I personally find the message contained herein a little misleading (it certainly cost me a few minutes the first time I encountered it for this reason) but the underlying cause was clear once I consulted the WCF Diagnostic Trace Logs.

提交回复
热议问题