Find out that the problem was the following
My solution structure is as follwoing:
Solution
|
+-- WebService (ASP webservice)
|
+-- Client (Class Library)
|
+-- TestUI (WinForms Application)
The WSE 3.0 Configuration were in the WebService web.config and policy.config (referenced by web.config) files (For the server)
And in app.config and policy.config (referenced by the app.config) in Client (For the client)
The policy.config for the Client had a policy section as follows
<policy name="ClientPolicy">
<mutualCertificate11Security establishSecurityContext="true" renewExpiredSecurityContext="true" requireSignatureConfirmation="true" messageProtectionOrder="SignBeforeEncrypt" requireDerivedKeys="true" ttlInSeconds="300">
<clientToken>
<x509 storeLocation="LocalMachine" storeName="My" findValue="CN=CertificateForClient" findType="FindBySubjectDistinguishedName" />
</clientToken>
<serviceToken>
<x509 storeLocation="LocalMachine" storeName="AddressBook" findValue="CN=CertificateForServer" findType="FindBySubjectDistinguishedName" />
</serviceToken>
<protection>
<request signatureOptions="IncludeAddressing, IncludeTimestamp, IncludeSoapBody" encryptBody="true" />
<response signatureOptions="IncludeAddressing, IncludeTimestamp, IncludeSoapBody" encryptBody="true" />
<fault signatureOptions="IncludeAddressing, IncludeTimestamp, IncludeSoapBody" encryptBody="false" />
</protection>
</mutualCertificate11Security>
<requireActionHeader />
</policy>
The problem was that, as the start project was TestUI, the app.config that loads is the one on that project, and not the one in the Client project, thus, not loading the policy.config in Client project.
That makes that the following line in the client fails
webService.SetPolicy("MyCustomPolicy");
with the ArgumentOutOfRangeException.
So...the solution I found...copy the policy file in the TestUI project and reference it from the app.config in that project.
Although I don't like that solution...IMHO they are different projects, and their configurations should be independient.
I'm guessing that there is a way to solve this, but I can't figure out how. If someone knows how, plase tell.
So...that solved the problem. Now I'm having a WSE error in which states:
WSE910: An error happened during the processing of a response message,
and you can find the error in the inner exception. You can also find
the response message in the Response property.
and the inner exception states:
Security requirements are not satisfied because the security header is
not present in the incoming message.
I'm guessing certificate problems. I barely could take a look at your answer Espen, but for what I see, it may help me to solve this new problem that appears. So thanks a lot for your answer.
Hope this helps to anybody that runs into the same situation that I did.
Cheers