by Euo
16. March 2010 14:32
Let say in your code you already have an instance of XmlDocument and you want to manipulate it easily, you can use the XDocument to do that.
Just for example, let us load an xml from existing file.
// read the xml
StreamReader srr = new StreamReader(@"c:\composite.xml");
// load in XmlDocument
XmlDocument doc = new XmlDocument();
doc.Load(srr);
// create XmlNodeReader
XmlNodeReader nodereader = new XmlNodeReader(doc);
// load in XDocument
XDocument xd = XDocument.Load(nodereader);
// you can now traverse in its descendants much more easily
foreach (var x in xd.Descendants())
{
if (x.NodeType == XmlNodeType.Element && !x.HasElements)
{
Console.WriteLine("Name:{0}, Value:{1}", x.Name, x.Value);
x.SetValue((object)x.Value + "_x");
}
}
// save it for comparison
xd.Save(@"C:\composite_xd.xml", SaveOptions.None);
// load it back to XmlDocument
doc.Load(xd.CreateReader());
// save it for comparison
doc.Save(@"C:\composite_xmldoc.xml");
39bbfe14-ab44-4662-8b44-b003e478fe56|0|.0
Tags:
Development
by Euo
9. March 2010 17:47
The error below comes up when I try to send 8kb message across WCF.
System.ServiceModel.FaultException`1 was unhandled
Message="The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:encrptedString. The InnerException message was 'There was an error deserializing the object of type System.String. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader
The resolution here is to add maxReceivedMessageSize to binding configuration as below (both client and service):
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IPayloadSvc" maxReceivedMessageSize="2147483647" >
<readerQuotas
maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</wsHttpBinding>
</bindings>
by Euo
8. March 2010 16:06
This usually happens when you have application consuming WCF and you have errors in configuration file (web or app.config), either unclosed tags or mismatch tags.
9483710e-1e6c-4f6d-b9db-2e5ef570d508|2|1.0
Tags:
Development
by Euo
5. March 2010 10:59
Active Web Solutions made a library to connect hassle-free to any TCP ports even sitting behind network infrastracture firewall using AppFabric Service Bus. It was based on Port Bridge which Clemens Vasters explained here - but lighter.
I tested it by publishing a WCF service in my development machine and consuming that service from other machine sitting behind firewall and different network domain.
I also tried Port Bridge and they both rocks!
Check SocketShifter at Codeplex.
Check Port Bridge here.