Brian,
You are reading from the stream, but you are not resetting the
position,
it would seem. You basically want to do this before you read the data
set:
// Set the position to the beginning.
sr.BaseStream.Position = 0;
// Discard buffered data.
sr.DiscardBufferedData();
// Read normally.
That should work.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
Thanks for the quick reply. I am passing it in as a StreamReader, as I
am
using the same StreamReader to pull out the signature and verify it.
Below
is
the code that i am using.
sr is the StreamReader that contains the file
XmlDocument doc = new XmlDocument();
doc.Load(sr);
SignedXml verifier = new SignedXml(doc);
verifier.LoadXml(doc.GetElementsByTagName("Signature")[0] as
XmlElement);
if (verifier.CheckSignature())
{
this.GetConfigFileToScreen(sr);
}
public void GetConfigFileToScreen ( StreamReader sr )
{
DataSet ds1 = new DataSet();
ds1.ReadXml(sr); // This is the error line.
:
Brian,
I saved that XML document to a file, and then loaded it into a
DataSet
without any problems. Are you sure this is the right file, and how
are
you
loading it into the DataSet?
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
message
Here is an example of the file. The file is used to create 3
datatables
in
the DataSet, I used the signature information in the first node
position
and
the last node. This example shows the signature in the first
position
using
the XmlDocument.DocumentElement.PrependChild() method.
Thanks
<?xml version="1.0" encoding="utf-8"?>
<FWT>
<Signature xmlns="
http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod
Algorithm="
http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
<SignatureMethod
Algorithm="
http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
<Reference URI="">
<Transforms>
<Transform
Algorithm="
http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
</Transforms>
<DigestMethod
Algorithm="
http://www.w3.org/2000/09/xmldsig#sha1"
/>
<DigestValue>hxyhMOAfdFJYOsDlADHTah0Gmmg=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>rakRKha0vAX8cIsFwhJUsgzOB1NMNW6viG/EsTUivy4Rt3Cg2k1LDTkmJv+bXhgWBoPBtdMxg9ZSXah0P1qw5K/1npSWPmJ9uWGEQuWwZT5KqJNfq1iy7QKfUiKGTn1q+0Mc2WXPo18v6Fnuqqh7+btrpfnvbTaKJ0mQHAw9H+0=</SignatureValue>
<KeyInfo>
<KeyValue xmlns="
http://www.w3.org/2000/09/xmldsig#">
<RSAKeyValue>
<Modulus>01k61JX5bc/jCLnnEHtzw3o08hs6+KjE58md8wkRrBgTTEU3gtmD1Q8SxPxpJiSwGNRCWTAghxSrK7AFYOCGZTblstnHerqs0Z/LTVNW2JaVkI34kvquqWdd6JJ+GNYWWuKuTiTjyEpLSikjXXFTWkLJqDU/w1Lq6MN6g+z6lx8=</Modulus>
<Exponent>AQAB</Exponent>
</RSAKeyValue>
</KeyValue>
</KeyInfo>
</Signature>
<FWT_CONFIG>
<keyName>#PEREXEMPAMT</keyName>
<keyValue>3100</keyValue>
</FWT_CONFIG>
<FWT_FORMULA>
<Step>1</Step>
<Token>MUL</Token>
<Arg1>@TAXWAGES</Arg1>
<Arg2>@PAYPERIODS</Arg2>
<Arg3>ANNUALWAGE</Arg3>
<Arg4 />
<Arg5 />
<Arg6 />
<Arg7 />
<Arg8 />
<DefValue>0</DefValue>
<Comment />
</FWT_FORMULA>
<FWT_TAXTABLES>
<filingStatus>1</filingStatus>
<taxTableId>3</taxTableId>
<baseWage>9700</baseWage>
<upperWage>30800</upperWage>
<taxAmt>705</taxAmt>
<taxRate>0.15</taxRate>
</FWT_TAXTABLES>
<FWT_TAXTABLES>
<filingStatus>1</filingStatus>
<taxTableId>4</taxTableId>
<baseWage>30800</baseWage>
<upperWage>68500</upperWage>
<taxAmt>3870</taxAmt>
<taxRate>0.25</taxRate>
</FWT_TAXTABLES>
</FWT>
:
Brian,
Can you post an example of the signed document?
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
message
I have XML Documents that I am digitally signing, and need to be
able
to
load
these documents into DataSet objects. However, after checking the
signature
and using the DataSet.ReadXML method, I am getting an exception
"The
root
element is missing".
I have struggled over the last 24 hours trying to figure out ways
of
correcting this, however I am stuck. I would appreciate any help
that
the
community can provide me on this.
Thanks,