Question

I only need to sign one specific field inside a WCF message. The class has the next aspect:

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.ServiceModel.MessageContractAttribute(WrapperName="simpleInputData",
    ProtectionLevel = ProtectionLevel.None
   , IsWrapped=true)]
public partial class SimpleOperationRequest
{

    [System.ServiceModel.MessageHeaderAttribute(
      ProtectionLevel = ProtectionLevel.None)]
    public BusinessHeader businessHeader;

    [System.ServiceModel.MessageHeaderAttribute(
        ProtectionLevel = ProtectionLevel.None)]
    public TechnicalHeader technicalHeader;

    [System.ServiceModel.MessageBodyMemberAttribute(
        ProtectionLevel = ProtectionLevel.Sign, Order = 0)]
    public SimpleInput simpleInput;

    [System.ServiceModel.MessageBodyMemberAttribute(
         ProtectionLevel = ProtectionLevel.None, Order = 1)]
    public Attachment attachment;

    [...]
}

As you can see, I only need sign simpleInput field, but, when I run the code, the package sent is (only show the body node):

[...]      
<s:Body u:Id="_3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <simpleInputData xmlns="http://xxxx/simple">
          <simpleInput>
            <in>llega?</in>
          </simpleInput>
          <attachment>
            <ImageData>iVBORw0K...5CYII=</ImageData>
          </attachment>
        </simpleInputData>
      </s:Body>
    [...]

In the code, you can see that the whole body node is signed.

How could I obtain only the node "simpleInput" signed??

Thanks a lot in advance!

Was it helpful?

Solution

Not possible in WCF. You must sign the whole body or nothing of it. You could choose which headers to sign though.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top