Solved

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

Posted on 2007-11-16
5
3,543 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
[X]
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
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

691 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