I have a WCF web service built in .NET 4.0 that is configured to require a username/password on each call and uses a Server certificate in the behaviour to encrypt the request. It currently uses wsHttpBinding. I have a .NET 4 utility app that lets me call the methods on this WCF web service just fine.
I need to call this service from a .NET 2.0 class library. The library is in VS 2010 but targetting .NET 2.0 - I would like to simply switch to .NET 4.0 but can't for political reasons and time constraints. So therefore wsHttpBinding and the server certificate as used now are out of the question from what I've read so far.
From reading bits and pieces I did the following:
- Changed the binding to use basicHttpBinding
- Removed mention of the server certificate from the behaviours
- Installed and enabled WSE on the class library project.
- Try to use on the WCF web service methods in .NET 2.0 winforms app - epic fail!!
It doesn't matter how I seem to configure the binding at the server end HTTPS is just not acceptible; the only way to get it to let me call it at all is do use security mode of "None", grrrghhh! That of course allows me to call it but then the username/password details are not supplied and never get set on the WCF service and hence when it eventually tries to save it fails because the user ID is 0.
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false"/>
<services>
<service name="MyService.NameHere" behaviorConfiguration="NameOfMyConfigHere">
<endpoint binding="basicHttpBinding" bindingConfiguration="basicBinding" contract="DirectoryServices.IDirectorySubmitService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyBehaviourName">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="basicBinding" maxReceivedMessageSize="5242880">
<readerQuotas maxStringContentLength="5242880"/>
<security mode="None">
<transport clientCredentialType="Basic" proxyCredentialType="Basic" />
<message clientCredentialType="UserName"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
If anyone could help me figure out the correct magic mumbo to put in I would be most appreciated.
All I want to do is call a WCF web method supplying a username/password and have it use SSL to encrypt. The service is running on IIS. The client is a winforms app.