Why WCF SoapFault responses are encrypted in some situations?
Asked Answered
I

1

8

I am creating a WCF webservice whose requests/responses are supposed to be signed only. For this, on ServiceContract attribute I have set

ProtectionLevel = ProtectionLevel.Sign

That works ok.

Due to requirements some SoapFaults are supposed to be thrown from service; two types of SoapFaults:

  • related to application
  • related to WS-Addressing (e.g. MessageID is missing)

For this I am using the normal of approach of dealing with SoafFaults: create an IErrorHandler in which a Message instance is created with MessageFault.CreateFault.

Almost all the returned SoapFaults are not encrypted (which is ok for me), my question is why the ones with action="http://www.w3.org/2005/08/addressing/fault" or "http://www.w3.org/2005/08/addressing/soap/fault" are encrypted?

Izzard answered 10/12, 2012 at 10:51 Comment(3)
how do you know it is encrypted? can you provide a sample response?Saran
I know is encrypted because I view it with SvcTraceViewer (on client side).Izzard
@Izzard have you found out why? I am having the exact same problem.Irreconcilable
K
0

Check out http://msdn.microsoft.com/en-us/library/aa347791.aspx and http://msdn.microsoft.com/en-us/library/system.servicemodel.faultcontractattribute.aspx. It states that

If you select a binding that enables security and you do not set the ProtectionLevel property anywhere on the contract, all application data will be encrypted and signed.

I guess that the build in types by default use this behaviour. You can verify this by looking at which exception is actually thrown.

Kapp answered 29/1, 2013 at 14:37 Comment(1)
The protection level is set at the contract level with: [ServiceContract(ProtectionLevel = ProtectionLevel.Sign)]Izzard

© 2022 - 2024 — McMap. All rights reserved.