0

我只需要在 WCF 消息中签署一个特定字段。该类具有下一个方面:

[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;

    [...]
}

如您所见,我只需要 sign simpleInput 字段,但是,当我运行代码时,发送的包是(仅显示正文节点):

[...]      
<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>
    [...]

在代码中,可以看到整个body节点都被签名了。

我怎样才能只获得节点“simpleInput”签名?

提前非常感谢!

4

1 回答 1

2

在 WCF 中不可能。您必须在整个正文上签字,否则一律不签字。您可以选择要签名的标题。

于 2013-09-27T13:55:11.263 回答