WCF- Sign a specific field inside the body of a soap message

半城伤御伤魂 提交于 2019-12-11 22:02:50

问题


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!


回答1:


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



来源:https://stackoverflow.com/questions/19051422/wcf-sign-a-specific-field-inside-the-body-of-a-soap-message

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!