Quantcast
Channel: WCF, ASMX and other Web Services
Viewing all articles
Browse latest Browse all 555

Problem when adding validation for WCF

$
0
0

I created a very simple WCF service library and then a WCF service application.  I was able to deploy the app to IIS on a server.  The URL to the .svc was accessible through my browser and I even created a Windows console application to test calling the web service from code.  Everything worked just fine.  But, I need to add authentication with a username/password.  I did some research and found an example that had me create a new class that inherited from UserNamePasswordValidator and then made changes to my web.config.  After testing everything locally I tried deploying the app to the server again.  This time the URL to the .svc would not resolve.  And my command line application gives me a strange error saying :

"Client found response content type of '', but expected 'text/xml'.".

Below is the web.config with the changes I made for the authentication commented out:

<?xml version="1.0"?><configuration><appSettings><add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /></appSettings><system.web><compilation debug="true" targetFramework="4.5" /><httpRuntime targetFramework="4.5"/></system.web><system.serviceModel><!--<services><service name="ServiceLib.HelloService" behaviorConfiguration="ServicesBehavior"><endpoint address="" binding="wsHttpBinding" contract="ServiceLib.IHelloService" bindingConfiguration="ServicesConfig"></endpoint></service></services><bindings><wsHttpBinding><binding name="ServicesConfig"><security mode="Message"><message clientCredentialType="UserName"/></security></binding></wsHttpBinding></bindings>
    --><behaviors><serviceBehaviors><behavior><!--<behavior name="ServicesBehavior">--><serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/><serviceDebug includeExceptionDetailInFaults="false"/><!--<serviceCredentials><clientCertificate><authentication certificateValidationMode="None" /></clientCertificate><userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="ServiceLib.ServiceAuthenticator,ServiceLib" /><serviceCertificate findValue="Services" x509FindType="FindBySubjectName" storeName="My" storeLocation="CurrentUser" /></serviceCredentials>
          --></behavior></serviceBehaviors></behaviors><protocolMapping><add binding="basicHttpsBinding" scheme="https" /></protocolMapping><serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /></system.serviceModel><system.webServer><modules runAllManagedModulesForAllRequests="true"/><directoryBrowse enabled="true"/></system.webServer></configuration>

Using the web.config with everything regarding the authentication commented out I can get my web service to work again, but I need to have username/password authentication.

Any help would be greatly appreciated.


Viewing all articles
Browse latest Browse all 555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>