Forum Discussion

sudhaMurugesan's avatar
sudhaMurugesan
New Contributor
10 years ago

Modify xmlAttribute Name like xsi:type

I am created class for Response. Class name is TestResponse. I need to add attribute xsi:type="xsd:Boolean" like that.

But i cant give that attribute name is "xsi:type".

I need any guidance to add xsi before type tag.

 

Class:

[DataContract(Namespace = "urn:test:datacontracts")]
public class TestResponse
{  
        private Date _date;
        public Date data
        {
            get { return _date; }
            set { _date = value; }
        }   
        [DataContract]
        public class Date
        {
            [DataMember, XmlAttribute]
            public string type = "xsd:boolean";

            [DataMember, XmlText]
            public Boolean data;
        }
}

 

My Response:

 

<TestResponse>
         <cancelResult>
                <data type="xsd:boolean">false</data>
         </cancelResult>
      </TestResponse>

 

Expected Response

 

<TestResponse>
       <data xsi:type="xsd:boolean">false</data>
</TestResponse>

 

4 Replies

  • kondasamy's avatar
    kondasamy
    Regular Contributor

    As mentioned in another similar post, please post this query in WCF related forums. 

     

    Thanks,

    Samy

  • nmrao's avatar
    nmrao
    Community Hero
    Have you checked the wsdl what is input and output?
    • sudhaMurugesan's avatar
      sudhaMurugesan
      New Contributor

      Checked i am getting this following result only. But how to add xsi in front of type attribute. I am using .net 2012.  soap ui 5.2.1

       

      Request:

       

      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="web:webservice.com">
         <soapenv:Header/>
         <soapenv:Body>

      <CancelRequest>
               <arg0>
                  <UserName>?</UserName>    

                  <PhoneNo> ?</PhoneNo>
               </arg0>

      </CancelRequest>

      </soapenv:Body>
      </soapenv:Envelope>

       

      Response:

       

      <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
         <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

      <cancelResponse>
               <cancelResult>        
                     <data type="xsd:boolean">false</data>
               </cancelResult>
        </cancelResponse>

       </s:Body>
      </s:Envelope>