xml-deserialization

How to deserialize soap response?

ⅰ亾dé卋堺 提交于 2020-01-25 01:49:46
问题 I'm trying to deserialize following xml to c# object: <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> <S:Body> <ns2:topupResponse xmlns:ns2="http://www.claro.com.hn/esb/ws/topups/" xmlns:ns3="http://www.claro.com.hn/esb/ws/ops/"> <result> <conversionRate>7.7765</conversionRate> <datetime>2018-01-10T08:33:19.685-06:00</datetime> <distAmount>5.00</distAmount> <msisdn>50279613880</msisdn> <newBalance>38</newBalance> <operAmount>38.882500</operAmount> <responseCode>0<

Jackson empty xml array deserialization

痴心易碎 提交于 2020-01-24 06:38:26
问题 I have an incoming xml from Recurly service with list of transactions. Sometimes it's empty and looks like this: <transactions type="array"> </transactions> I need to deserialize this using Jackson. I've tried next mapping @XmlRootElement(name = "transactions") public class TransactionObjectListResponse extends ArrayList<TransactionObjectResponse> { } where TransactionObjectResponse class for each transaction. It works fine for non-empty collections, but fails when no transactions came. Next

How to deserialize a numbered array of XML elements

别等时光非礼了梦想. 提交于 2020-01-15 11:55:29
问题 I need to deserialize the following XML: <TIMEWINDOWS> <NUMBER>10</NUMBER> <NO0> <FROM>22-11-2013 08:00:00</FROM> <TO>22-11-2013 11:59:00</TO> </NO0> <NO1> <FROM>22-11-2013 12:00:00</FROM> <TO>22-11-2013 15:59:00</TO> </NO1> <NO2> <FROM>23-11-2013 08:00:00</FROM> <TO>23-11-2013 11:59:00</TO> </NO2> <NO3> <FROM>23-11-2013 12:00:00</FROM> <TO>23-11-2013 15:59:00</TO> </NO3> ... </TIMEWINDOWS> The output that I require is a collection (list, array, whatever) of TimeWindow objects, for example:

Exclude null properties in JMS Serializer

半城伤御伤魂 提交于 2020-01-14 17:55:54
问题 My consumed XML API has an option to retrieve only parts of the response. This causes the resulting object to have a lot of NULL properties if this feature is used. Is there a way to actually skip NULL properties? I tried to implement an exclusion strategy with shouldSkipProperty(PropertyMetadata $property, Context $context)` but i realized there is no way to access the current property value. An example would be the following class class Hotel { /** * @Type("string") */ public $id; /** *

Exclude null properties in JMS Serializer

橙三吉。 提交于 2020-01-14 17:54:17
问题 My consumed XML API has an option to retrieve only parts of the response. This causes the resulting object to have a lot of NULL properties if this feature is used. Is there a way to actually skip NULL properties? I tried to implement an exclusion strategy with shouldSkipProperty(PropertyMetadata $property, Context $context)` but i realized there is no way to access the current property value. An example would be the following class class Hotel { /** * @Type("string") */ public $id; /** *

Convert XML with duplicate elements to JSON using jackson

安稳与你 提交于 2020-01-14 09:34:10
问题 I have some simple data in XML format which I need to convert to JSON and also be able to convert the JSON back into the same XML string. But I'm having problems with doing this using existing jackson (version 2.0.6) libraries. Here's an example of XML data with similar structure <channels> <channel>A</channel> <channel>B</channel> <channel>C</channel> </channels> To be able to convert this back to the original XML, I'd like the JSON to look something like this { "channels": { "channel": [ "A

Instance validation error: * is not a valid value for *

亡梦爱人 提交于 2020-01-13 10:16:09
问题 I'm trying to deserialize an XML string, where the value of an element, ain't within the scope of my Enum values. Public enum MyEnum { Unknown, Car, Bicycle, Boat } [SerializableAttribute()] public class MyClass { private string _id; private MyEnum _myEnum; public string ID { get { return _id; } set { _id = value; } } public MyEnum EnumValue { get { return _myEnum; } set { _myEnum = value; } } public MyClass(string id) { this._id = id; } public MyClass() : this("") { } } If I try to

HttpClient ReadAsAsync<Type> only deserializing part of the response

谁说我不能喝 提交于 2020-01-07 03:27:09
问题 I am using the following to make a call to a WebAPI using (HttpClient client = HttpClientFactory.Create(new AuthorisationHandler())) { client.BaseAddress = new Uri(BaseURI); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); var httpResponseMessage = await client.PostAsXmlAsync<AvailRequest>("Avail/Search/", req); httpResponseMessage.EnsureSuccessStatusCode(); var availResp =

How to deserialize the xmlelement containing List in xml

故事扮演 提交于 2020-01-06 14:19:55
问题 I am using silverlight5 and c# to achieve my targets. I have xml file below: string xmlstring = <?xml version="1.0" encoding="utf-8" ?> <parameter> <name>bands_amounts</name> <label>Bands Amounts</label> <unit></unit> <component> <type>List</type> <attributes> <type>Integer</type> <displayed>4</displayed> <add_remove>yes</add_remove> <item>1 000 000</item> <item>5 000 000</item> <item>10 000 000</item> <item>20 000 000</item> </attributes> <attributes> <ccypair>XAUUSD</ccypair> <item>100<

How to deserialize the xmlelement containing List in xml

十年热恋 提交于 2020-01-06 14:18:02
问题 I am using silverlight5 and c# to achieve my targets. I have xml file below: string xmlstring = <?xml version="1.0" encoding="utf-8" ?> <parameter> <name>bands_amounts</name> <label>Bands Amounts</label> <unit></unit> <component> <type>List</type> <attributes> <type>Integer</type> <displayed>4</displayed> <add_remove>yes</add_remove> <item>1 000 000</item> <item>5 000 000</item> <item>10 000 000</item> <item>20 000 000</item> </attributes> <attributes> <ccypair>XAUUSD</ccypair> <item>100<