xmlSerializer---root object --namespace prefix

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • siddharthkhare@hotmail.com

    #1

    xmlSerializer---root object --namespace prefix

    HiAll,
    i am having hard time serializing a object in a specific xml.I need to
    feed it to a biztalk port.


    i Have a root object(c# class) 'CTSCServiceOrd er'.

    When i serilize it using a xml serializer following is the out put.

    <?xml version="1.0"?>
    <CTSCServiceOrd er
    xmlns="ns0:http ://CTSC.SI.Delinqu ency.BizTalk.In Request"
    xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance" IsOperation="0" >
    .......Rest of the child here
    </CTSCServiceOrde r>

    I want to get a output as shown below...Want to have prefix in front of
    the 'CTSCServiceOrd er' element


    <?xml version="1.0"?>
    <ns0:CTSCServic eOrder
    xmlns="ns0:http ://CTSC.SI.Delinqu ency.BizTalk.In Request"
    xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance" IsOperation="0" >
    .......Rest of the child here
    </ns0:CTSCService Order>


    and i have tried following solution

    1)srRequest = new
    XmlSerializer(t ypeof(CTSCServi ceOrder),"ns0:h ttp://CTSC.SI.Delinqu ency.BizTalk.In Request");

    2)[XmlRoot("CTSCSe rviceOrder",
    Namespace="ns0: http://CTSC.SI.Delinqu ency.BizTalk.In Request" )]

    public class CTSCServiceOrde r {......}

    3)[System.Xml.Seri alization.XmlTy peAttribute(Nam espace="ns0:htt p://CTSC.SI.Delinqu ency.BizTalk.In Request")]



    I could get the namespace defined using the solution i mentioned above
    but it does not prefix the root element with the prefix.


    CTSCServiceOrde r class is the root class.


    Is there a way to do this?
    Thanks
    siddharth

Working...