开发者

How to sign an xml file in a wcf service?

I'd like my WCF service to return an xml file that has been signed.

I found documentation that shows how to sign an XmlDocument on msdn, but since 开发者_如何学JAVAa WCF function can't return an XmlDocument I'm not sure if the following would work (similar to thisquestion)

public XmlElement GetXml() {
        var doc = new XmlDocument();
        // add data to doc
        // sign doc
        return doc.DocumentElement;
    }

Would it still be possible to verify the signature of doc.DocumentElement if I added it to another XmlDocument after a client requested it? Is there a better way to do this?

Thanks!


XmlDocument is not decorated with DataContractAttribute and I cannot see why the object needs to be sent over the wire while the serialized form (text form) is all that is required.

I would design it as:

[OperationContract]
string GetFooXml();

And send the string. That is what WCF/XML is for, sending data as text whenever possible so that more kinds of clients can consume it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜