WCF client, WSE service, UsernameOverCertificate



Hi,

I have an existing WSE3 implementation using UsernameOverCertificate and decided the best way to migrate to WCF was to migrate the client first and the service later.

After studying the available samples (e.g. http://msdn2.microsoft.com/en-us/library/ms752257.aspx) I have managed to migrate the client but still have a few issues.
They are:
1) It doesn't work if I set EstablishSecurityContext=true in the client and set establishSecurityContext="true" in the service's policy.
2) Our service populates SoapException.Detail with extra information when raising an exception. The WCF client rejects this with:
System.ServiceModel.CommunicationException
Server returned an invalid SOAP Fault. Please see InnerException for more details.
End element 'Fault' from namespace 'http://www.w3.org/2003/05/soap-envelope' expected. Found element 'detail' from namespace ''.
3) If the server throws any SoapException (without setting the fault detail) the client reports
"The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state."
and no further information appears to be available.

So my questions are:
1) Is it possible to use EstablishSecurityContext with WCF -> WSE3 and if so how?
2) Is it possible to configure the WCF client to accept the custom fault detail information?
3) I would have thought exception info generated by a WSE3 service be available in a WCF client. What's going wrong?

I can post my test code if required, however the basics are below.
The WCF client can be configured using app.config + some code, or all in code.

This is the .config version:

<configuration>
<system.serviceModel>
<behaviors />
<bindings>
<customBinding>
<binding name="Service1Wse">
<security authenticationMode="UserNameForCertificate" messageProtectionOrder="SignBeforeEncrypt">
<secureConversationBootstrap messageProtectionOrder="SignBeforeEncrypt" requireDerivedKeys="true" />
</security>
<textMessageEncoding messageVersion="Soap12WSAddressingAugust2004" />
<httpTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://localhost:2345/Service1.asmx"; binding="customBinding"
bindingConfiguration="Service1Wse" contract="Service.Service1Soap"
name="Service1WseEndPoint">
<identity>
<dns value="Test" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>

This is the code version:

EndpointAddress address = new EndpointAddress(new Uri("http://localhost:2345/Service1.asmx";),
EndpointIdentity.CreateDnsIdentity("Test"));

WseHttpBinding binding = new WseHttpBinding(); // from "Interoperating with WSE" sample (http://msdn2.microsoft.com/en-us/library/ms752257.aspx)

binding.SecurityAssertion = WseSecurityAssertion.UsernameForCertificate;
binding.EstablishSecurityContext = false;
binding.RequireDerivedKeys = true;
binding.MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncrypt;

Service1SoapClient client = new Service1SoapClient(binding, address);

Plus configure certificate in code:

ClientCredentials clientClientCredentials = client.ClientCredentials;

UserNamePasswordClientCredential userNamePassword = clientClientCredentials.UserName;
userNamePassword.UserName = "user";
userNamePassword.Password = checkBox1.Checked ? "password" : "rubbish";
clientClientCredentials.ServiceCertificate.SetDefaultCertificate(StoreLocation.LocalMachine,
StoreName.My,
X509FindType.FindBySubjectDistinguishedName,
"CN=Test");

Regards,
Phil Lee

.



Relevant Pages

  • RE: WCF Security Issue
    ... ** Is your WCF service designed to use domain ... both wsHttpbinding and netTcpBinding support message ... Then, for your WCF client, you can use the current logon user's credential ... Microsoft MSDN Online Support Lead ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: System.Configuration does not support config files for libraries.
    ... Seems what you want to do is sharing some custom classes/types between the WCF service and client application. ... For WCF there is type sharing support. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: WCF Contract Design Best Practices Question
    ... don't have to worry about maintaining client apps. ... I had this thought that I could host my WFC client proxies in this library ... my WCF object I'm still going to have to ... properties that are used just for the web service. ...
    (microsoft.public.dotnet.framework.webservices)
  • RE: Comet implementation in WCF
    ... As for the WCF Comet service scenario you mentioned, ... So far based on my research, at server-side, WCF method can use ... Microsoft MSDN Online Support Lead ... I am developing a WCF Comet web service, where client requests gets queued ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • RE: MessageSecurityException when consuming WCF service
    ... I am not sure whether this is an appropriate place to ask WCF query. ... client application it fails and throws an exception. ...
    (microsoft.public.dotnet.languages.csharp)