none
Wcf serialization issue with XmlElement [ ] RRS feed

  • Question

  • Iam trying to add few items to XelementArray [] which is a part of wcf request object.

    In the generated proxy class the property is defined as

    private XmlElement[] MetaData;

    Am adding element to this xelement array as below

          XmlElement[] MetaDataDoc = new XmlElement[10];
                string fileName = string.Empty;
                var xmldocm = new XmlDocument();
                xmldocm.Load(fileName);
                MetaDataDoc = xmldocm.DocumentElement.ChildNodes.Cast<XmlElement>().ToArray();

    If i add a breakpoint i could see only the child nodes are added  to the array . Am then setting this MeteDataDoc to MetaData property of wcf request

    Here is the sample xml which i loaded to add elements to xmlarray

    <DocumentTemplate>
      <MetaData>
        <FileName>Account Details</FileName>
        <Description>Account Details</Description>
        <Language>English - US</Language>
        <BusinessChannel>
          <Inbound>true</Inbound>
        </BusinessChannel>
      </MetaData>
    </DocumentTemplate>

    But when wcf serializes the request its coming like below...adding the MetaData node multiple times..and adding elements under that .

    Not adding element under  single MetaData node

      <MetaData>
        <FileName>Account Details</FileName>
      </MetaData>
      <MetaData>
      <Description>Account Details</Description>
      </MetaData>
      <MetaData>
         <Language>English - US</Language>
      </MetaData>
      <MetaData>
        <BusinessChannel>
          <Inbound>true</Inbound>
        </BusinessChannel>
      </MetaData>

    Please help me out to resolve this issue 

    Many Thanks

    Monday, September 29, 2014 8:47 PM

All replies