C#, XML, XML Prefixes, and Signing XML Documents with Prefixes

For those tasked with integrating an API from a company that starts with an R and ends with a one. Here are some links that may prove useful:

Digitally Signing an XML Document and Verifying the Signature

Here’s a PDF of the article, in case it ever get’s taken down.

I didn’t use C# to create the XML document. Instead, I used a Razor template to generate the XML.

How did I sign an XML document with an XML prefix?

Reference this Stack Overflow thread. Check the answer submitted by George Dima. [Thank you George.]  Reference in case it ever gets taken down.

I didn’t realize that you can’t sign an XML document with a prefix in .NET using the objects provided as is. It took me awhile to figure out that this was causing a validation issue with the XML signature.

How do I Http Post in C#?

Reference the code here or just download it here.

There’s an easier way using the WebClient object, but if you can’t use the latest version of the .NET framework, the above will work fine in all cases.