xml-serialization

Sending object to WCF service. MaxStringContentLength (8192 bytes) exceeded when deserializing

Deadly 提交于 2019-12-31 03:58:25
问题 I created a simple WCF web service that has one method: SubmitTicket(flightticket ft, string username, string password) On the client side, I have an application for filling out a form (a flight ticket) and sending it to this newly created web service. When this flightticket object exceeds 8192bytes I get the following error: "There was an error deserializing the object of type flightticket. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota

Incomplete XML attribute

ぐ巨炮叔叔 提交于 2019-12-31 03:03:31
问题 I am creating XML out of Dataset by dataset.GetXML() method. I want to add attributes to it XmlAttribute attr = xmlObj.CreateAttribute("xmlns:xsi"); attr.Value = "http://www.createattribute.com"; xmlObj.DocumentElement.Attributes.Append(attr); attr = xmlObj.CreateAttribute("xsi:schemaLocation"); attr.Value = "http://www.createattribute.com/schema.xsd"; xmlObj.DocumentElement.Attributes.Append(attr); xmlObj.DocumentElement.Attributes.Append(attr); But when I open the XML file, I found "xsi:"

Incomplete XML attribute

China☆狼群 提交于 2019-12-31 03:03:06
问题 I am creating XML out of Dataset by dataset.GetXML() method. I want to add attributes to it XmlAttribute attr = xmlObj.CreateAttribute("xmlns:xsi"); attr.Value = "http://www.createattribute.com"; xmlObj.DocumentElement.Attributes.Append(attr); attr = xmlObj.CreateAttribute("xsi:schemaLocation"); attr.Value = "http://www.createattribute.com/schema.xsd"; xmlObj.DocumentElement.Attributes.Append(attr); xmlObj.DocumentElement.Attributes.Append(attr); But when I open the XML file, I found "xsi:"

Putting each attribute on a new line during xml serialization

旧巷老猫 提交于 2019-12-31 02:46:24
问题 Lets say I have a DOM object (or a string containing xml). Is it in any way possible to serialize the xml in such a way that each attribute appears on a new line? This is the output I want: <parent> <anElement attrOne="1" attrTwo="2" attrThree="3" /> </parent> Preferred if the solution a part of the standard java api, but I suspect such a feature is not available in there, or am I wrong? I found a property for a serializer in the .NET Framework, called NewLineOnAttributes. What I am searching

Ignore property of a property in Xml Serialization in .NET using XmlSerializer

感情迁移 提交于 2019-12-31 00:57:28
问题 I am carrying out Xml serrialization using XmlSerializer . I am carrying out serialization of ClassA , which contains property named MyProperty of type ClassB . I don't want a particular property of ClassB to be serialized. I have to use XmlAttributeOverrides as the classes are in another library. If the property was in ClassA itself, it would have been straightforward. XmlAttributeOverrides xmlOver = new XmlAttributeOverrides(); XmlAttributes xmlAttr = new XmlAttributes(); xmlAttr.XmlIgnore

How do I Set XmlArrayItem Element name for a List<Custom> implementation?

主宰稳场 提交于 2019-12-30 16:26:31
问题 I want to create a custom XML structure as follows: <Hotels> <Hotel /> </Hotels> I've created an implementation of List just to be able to do this. My code is as follows: [XmlRootAttribute(ElementName="Hotels")] public class HotelList: List<HotelBasic> Because the class that List holds is not named Hotel but HotelBasic my xml is like <Hotels> <HotelBasic /> </Hotels> How do I fix this without having to implement ISerializable or IEnumerable ? 回答1: Assuming you are using XmlSerializer , if all

XML Serialization using DataContractSerializer and XmlSerializer

杀马特。学长 韩版系。学妹 提交于 2019-12-30 11:12:12
问题 I have 2 service reference (WCF). the first visual studio generate code using DataContractSerializer the second one, visual studio generates code using XmlSerializer I can't change anything on the web server side. So I'm creating an object aggregating objects from both references. How can I serialize this object so it respect the serialization specification for a DataContractSerializer and for a XmlSerializer. If I use a DataContractSerializer I'll have every field from my reference 2

The Invulnerable XMLException

余生颓废 提交于 2019-12-30 09:32:29
问题 Background I serialize a very large List<string> using this code: public static string SerializeObjectToXML<T>(T item) { XmlSerializer xs = new XmlSerializer(typeof(T)); using (StringWriter writer = new StringWriter()) { xs.Serialize(writer, item); return writer.ToString(); } } And deserialize it using this code: public static T DeserializeXMLToObject<T>(string xmlText) { if (string.IsNullOrEmpty(xmlText)) return default(T); XmlSerializer xs = new XmlSerializer(typeof(T)); using (MemoryStream

Xml Serialization vs. “True” and “False”

一曲冷凌霜 提交于 2019-12-30 08:06:05
问题 I'm having an issue with deserializing an XML file with boolean values. The source XML files I'm deserializing were created from a VB6 app, where all boolean values are capitalized ( True , False ). When I try to deserialize the XML, I'm getting a System.FormatException: The string 'False' is not a valid Boolean value. Is there a way to say ignore case with an attribute? 回答1: You could read that value as a string into a string field, then have a readonly bool field that had an if statement in

Xml Serialization vs. “True” and “False”

依然范特西╮ 提交于 2019-12-30 08:05:41
问题 I'm having an issue with deserializing an XML file with boolean values. The source XML files I'm deserializing were created from a VB6 app, where all boolean values are capitalized ( True , False ). When I try to deserialize the XML, I'm getting a System.FormatException: The string 'False' is not a valid Boolean value. Is there a way to say ignore case with an attribute? 回答1: You could read that value as a string into a string field, then have a readonly bool field that had an if statement in