Archives by Tag 'XML'

WCF POX, JSON and SOAP Coexist

By admin - Last updated: Monday, August 16, 2010

Sometimes, we want to make a service available in different protocols so that clients could have an option to choose one of their favorite methods to consume the web services. Here we are going to talk about how to make one WCF service available in POX(Plain Old XML as XML for short), JSON and SOAP [...]

XML deserialization, XML undefined property becomes an empty list

By admin - Last updated: Wednesday, July 29, 2009

When deserialize XML into object, the object’s property becomes an empty list even if the property is absence from the XML, the expected behavior is the property is null. For example, given a class public class MyFoo     {         public string Id { get; set; }         [...]

XSLT 1.0, Join a list of elements’s value with separator

By admin - Last updated: Thursday, February 26, 2009

In order to join a sequence with a customized separator in XSLT 1.0, similar to C# function string.Join( array, separator), I’ve come up with a template which takes the sequence and separator as parameter. Given a sample XML <?xml version=”1.0″ encoding=”utf-8″ ?> <?xml-stylesheet type=”text/xsl” href=”ElementJoin.xslt”?> <Root>   <Years>     <int>2008</int>     <int>2009</int>   [...]

WCF Soap11 vs Soap11WSAddressing10 vs Soap11WSAddressingAugust2004 vs Soap12 vs Soap12WSAddressing10 vs Soap12WSAddressingAugust2004

By admin - Last updated: Sunday, February 22, 2009

I’ve done some quick test on WCF interoperability of the SOAP versions and WSAddressing. SOAP 1.1 vs SOAP 1.2 SOAP 1.2 is an extended version of SOAP 1.1, it does everything that SOAP 1.1 offers, SOAP 1.2 provides clear processing model and it is based on XML infoset, it has no dependency on the underlying [...]

XSLT XML transformation vs Object mapping

By admin - Last updated: Monday, February 9, 2009

I’ve run some tests on transformation from one XML schema to the other so that I can compare the performance between XSLT and XmlSerializer with object mapping as well as the Pros and Cons. It appears XSLT transformed my source XML to target XML faster than the object mapping since XSLT doesn’t take the type [...]

C# XmlSerializer, Add an attribute to an array element

By admin - Last updated: Friday, June 27, 2008

In order words, add an attribute to an object element after xml serialization, If you want something like, <Rats count=“2″>   <Rat>little rat</Rat>   <Rat>old rat</Rat> </Rats> The C# code is [XmlType(“Rats”)]     public class Rats     {         [XmlAttribute(“count”)]         public int Count { get; set; [...]

WSE UsernameToken Password SendHashed – Crack

By admin - Last updated: Monday, November 12, 2007

Using ServiceCapture, Ethereal, Charles or some SOAP sniffer software to inspect the XML sent on wire. Here is XML snippet in the SOAP header. <wsse:usernametoken wsu:id=”….” xmlns:wsu=”….”>     <wsse:username>xxxxxx</wsse:username>     <wsse:password type=”….”>            fCQCp/A9wFD/Gku0L+yF/u+0leg=      </wsse:password>     <wsse:nonce>eSM7S/iT0KyA39vuWPQcPQ==</wsse:nonce>     <wsu:created>1975-12-01T05:28:36Z</wsu:created>  </wsse:usernametoken> [STAThread] static void Main() { [...]

SQL 2005 generates XML comment, array of elements

By admin - Last updated: Monday, November 12, 2007

SELECT         ‘nameValue’ AS “@name”,         CAST(’<!– your comment –>’ AS XML),         ‘anotherValue’ AS “another”,         (SELECT ‘i’ AS “@name”, ’1′ AS “@value” FOR XML PATH(’item’), TYPE),         (SELECT ‘j’ AS “@name”, ’2′ AS “@value” FOR XML PATH(’item’), TYPE) [...]

XML Elements or Attributes in the world

By admin - Last updated: Thursday, November 1, 2007

Elements way is good at interoperability. Attributes way is good at size of the XML. <message>      <id>1</id>      <myword>Hello</myword> </message> <message id=”1″>      <myword>Hello</myword> </message> <message id=”1″>Hello</message> <message id=”1″ myword=”Hello” /> Which way do you prefer?