xml-serialization

WCF contracts - namespaces and SerializationExceptions

六眼飞鱼酱① 提交于 2019-12-24 09:50:57
问题 I am using a third party web service that offers the following calls and responses http://api.athirdparty.com/rest/foo?apikey=1234 <response> <foo>this is a foo</foo> </response> and http://api.athirdparty.com/rest/bar?apikey=1234 <response> <bar>this is a bar</bar> </response> This is the contract and supporting types I wrote [ServiceContract] [XmlSerializerFormat] public interface IFooBarService { [OperationContract] [WebGet( BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat =

converting hash to XML using xmlsimple in ruby

心不动则不痛 提交于 2019-12-24 09:37:04
问题 I have a hash of the following format { '1234' => {"key1"=>1234,"key2"=>"sdfsdf","key3"=>"sdfsdfs"}, '234' => {"key1"=>234,"key2"=>"sdfsdf","key3"=>"sdfsdfs"} } I want to convert it to xml like below <?xml version="1.0" encoding="UTF-8"?> <MyKeys> <MyKey> <Key1>1234/Key1> <Key2>sdfsdf</Key2> <Key3>sdfsdfs</Key3> </MyKey> <MyKey> <Key1>234/Key1> <Key2>sdfsdf</Key2> <Key3>sdfsdfs</Key3> </MyKey> </MyKeys> the issue is, xmlsimple is not doing that. instead of putting , it is creating <1234> tag.

A type of generic list deserialization class?

主宰稳场 提交于 2019-12-24 08:35:06
问题 OK, so here's the story so far. I could already deserialize individual objects using XmlSerializer , but deserializing lists was proving to be a real headache. I started out by trying to serialize List<Foo> and the serializer serialized multiple <Foo> XML structures inside a root <ArrayOfFoo> element. That proved to be problematic to deserialize, so it looks like I needed to have defined the 'ArrayOfFoo' element myself. So, I've got a class working that is a 'wrapper' for the list, as shown

Serializing to XML file creates invalid XML document (11,12) [duplicate]

三世轮回 提交于 2019-12-24 08:22:10
问题 This question already has an answer here : FileMode.Open and FileMode.OpenOrCreate difference when file exists? c# bug? (1 answer) Closed last year . I'm trying to save a class into an XML Document. The class looks Like this: public class Settings { public LDAP LDAP; public Miscellaneous Miscellaneous; } public class LDAP { public bool LoadLDAPData; public bool ShowLDAPRoutingMessage; } public class Miscellaneous { public bool MinusBeforeQuestion; public bool MinusBeforeDescription; } The

Generating Java Exceptions from XSD / binding Exceptions with JAXB2

丶灬走出姿态 提交于 2019-12-24 07:26:20
问题 For webservices we usually generate java beans with the maven-jaxb2-plugin and use JAXB2 marshalling in Spring. I am wondering how to handle (SOAP-)faults that are declared in the WSDL/XSD best. In the application I would like to use Java exceptions that are marshalled to the faults. Is this possible? I haven't found a way to generate exceptions with the sourcecode generation of the maven-jaxb2-plugin. Thanks! Update: I'd like to use spring-ws. But I guess the main problem is how to generate

Why is a field in an auto-generated class serialized into an element when defined as an attribute in the XSD?

我怕爱的太早我们不能终老 提交于 2019-12-24 06:37:22
问题 I'm trying to expose a fairly complex object as XML through a REST API (using WCF). However, the object is defined by an XSD file so I've generated classes using the xsd.exe tool. The problem is that it seems that when my object is serialized to XML, an attribute (defined in the xsd) is serialized into an element. And I don't get why. Currently, I'm assuming that my xsd somehow allows that, but I can't tell why. I don't do any custom serialization, I let the framework handle it. Can someone

XML Serialization is not including milliseconds in datetime field from Rails model

妖精的绣舞 提交于 2019-12-24 05:58:47
问题 By default, the datetime field from the database is being converted and stripping off the milliseconds: some_datetime => "2009-11-11T02:19:36Z" attribute_before_type_cast('some_datetime') => "2009-11-11 02:19:36.145" If I try to overrride the accessor for this attribute like; def some_datetime attribute_before_type_cast('some_datetime') end when I try "to_xml" for that model, I get the following error: NoMethodError (undefined method `xmlschema' for "2009-11-11 02:19:36.145":String): I have

XML Serialization in Windows 8

。_饼干妹妹 提交于 2019-12-24 05:28:22
问题 How can I Serialize Object in windows 8 Metro App Development to xml file ? I don't know how to create stream , when I create streamWriter I get error on the file direction StreamWriter nsw = new StreamWriter(@"C:\sample.xml"); Error: The best overload method match 'system.io.streamwriter..streamwriter(system.io.stream) has some invalid arguments this is the main code : StorageFolder storageFolder = KnownFolders.DocumentsLibrary; StorageFile sampleFile = await storageFolder.CreateFileAsync(

C# XML Deserialization W/ Default Values

流过昼夜 提交于 2019-12-24 03:50:30
问题 I've got an object that is being serialized / deserialized via the XmlSerializer in C#, .NET 3.5. One of the properties (and more in the future) is a collection: List where T is an enum value. This serializes / deserializes fine. We are also using a "default values" mechanism to provide default values for the object, in case the serialized version doesn't have any value set. as a simple example, here is what we are dong: public enum MyEnum { Value1, Value2 } public class Foo { public List

C# XML Serialization and Decimal Value

£可爱£侵袭症+ 提交于 2019-12-24 02:09:29
问题 I am using XmlSerializer to serialize a C# object that contains a decimal to a string of xml e.g. AnObject.ADecimalValue I am finding the precision is varying in particular even if I explicitly round as below some values are getting output with four values after the point e.g. 12564.39 gets output as 12564.3900 AnObject.ADecimalValue = decimal.Round(AnObject.ADecimalValue, 2); The serializing code is below. XmlSerializer serializer = new XmlSerializer(typeof(AnObject)); using (StringWriter