?
Solved

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

Posted on 2007-11-16
5
Medium Priority
?
3,566 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 750 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

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.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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:
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

801 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