Solved

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

Posted on 2007-11-16
5
3,480 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
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)

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now