Solved

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

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

773 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