WCF- Sign a specific field inside the body of a so

2019-09-05 03:41发布

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!

标签: wcf soap sign
1条回答
老娘就宠你
2楼-- · 2019-09-05 04:35

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

查看更多
登录 后发表回答