Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Set  xsi:type="soap-enc:Array" in the xml using c# .net

Posted on 2007-11-16
5
3,524 Views
Last Modified: 2013-11-18
Hi,
   I wanted to add  xsi:type="soap-enc:Array"  to the XML in the node PayFileDS using c# .net.
I tried with
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Type = Array)]
But nothing is allowing me to add xsi:type="soap-enc:Array"
Here is the sampe XML.

 ?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <soap:Body>
            <ClaimsEntry xmlns="ABC" name="ClaimsEntry">
                  <Comment xmlns="" xsi:nil="true"/>
                  <Catego xmlns="" xsi:nil="true"/>
                    <PayFileDS xsi:type="soap-enc:Array">
                        <__PayFileDS_elt>
                              <PL>11</PL>
                              <VF>001</VF>
                              <Svc>1</Svc>
                        </__PayFileDS_elt>
                  </PayFileDS>
            </ClaimsEntry>
      </soap:Body>
</soap:Envelope>


Thanks in advance for any Help!
-HK
0
Comment
Question by:computer12
  • 3
  • 2
5 Comments
 
LVL 27

Accepted Solution

by:
Dabas earned 250 total points
ID: 20302637
Hello computer12,

How does this look?



Regards,

Dabas
            //Assuming XmlDocument xd holds your document
            XmlNode PayFileDSNode = xd.GetElementsByTagName("PayFileDS")[0];
            XmlAttribute xa = xd.CreateAttribute("xsi:type", "xsi");
            xa.Value = "soap-enc:Array";
            PayFileDSNode.Attributes.Append(xa);

Open in new window

0
 
LVL 27

Expert Comment

by:Dabas
ID: 20302641
Dabas,



Dabas
Trying attaching the snippet again: 
Assuming xd holds your XmlDocument: 
            XmlNode PayFileDSNode = xd.GetElementsByTagName("PayFileDS")[0];
            XmlAttribute xa = xd.CreateAttribute("xsi:type", "xsi");
            xa.Value = "soap-enc:Array";
            PayFileDSNode.Attributes.Append(xa);

Open in new window

0
 

Author Comment

by:computer12
ID: 20312612
Hi,
   Here is the expected XML file and I need to add xsi:type="soap-enc:Array" for the PayFileDS node.
I don't know how to set this property.
I know how to set xmlns="" xsi:nil="true" using
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true)]
I tried the same way for xsi:type="soap-enc:Array" using Type = Array. But it didnot work.
Can some one help me solve this problem.


 <?xml version="1.0" encoding="utf-8" ?>
- <Request xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="webservices">
- <ClaimsEntry xmlns="webservicenamespace" name="ClaimsEntry">
  <Comment xmlns="" xsi:nil="true"/>
                  <Catego xmlns="" xsi:nil="true"/>
                    <PayFileDS xsi:type="soap-enc:Array">
                        <__PayFileDS_elt>
                              <PL>11</PL>
                              <VF>001</VF>
                              <Svc>1</Svc>
                        </__PayFileDS_elt>
                  </PayFileDS>
            </ClaimsEntry>
 </Request>


0
 
LVL 27

Expert Comment

by:Dabas
ID: 20315035
computer12,
Did you try my code?
I did and it did generate the xml you have repeated


Dabas
0
 

Author Comment

by:computer12
ID: 20352922
Hi Dabas,
    Thanks for your suggestion.But may be I m not clear about my question.
I have my webservice which communicates with the other webservice.I was given a proxy class and I need to generate the XML format as above.I  create an instance of that class and  pass the required fields.
This object will be serialized and generated the soap message.

[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public ClaimsEntryPayFileDS PayFileDS
        {
            //get,set properties
            }
I am able to set the property  
xsi:nil="true" using
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true)]
But could not set the property
 xsi:type="soap-enc:Array"
I tried different ways but was unable to set this property.
Any ideas?

Thanks in advance,
HK
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question