我只需要在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;
[...]
}
正如您所看到的,我只需要签署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>
[...]
在代码中,您可以看到整个身体节点已签名。
我怎么才能只获得节点“simpleInput”签名?
提前多多感谢!
答案 0 :(得分:2)
在WCF中不可能。你必须签署整个身体或没有任何标志。您可以选择要签名的标题。