none
Model in XML instead of class RRS feed

  • Question

  • Hi I am working on code I got from previous developer. it is wcf service and I see xml file where I expected class in the models section. the xml looks partly like this one. I am wondering what is the purpose of using xml instead of ordinary data contract class? I tried to google and I found that some times it is necessary in case to communicate with COM objects. I do not understand this part. I mean what is the scenario where xml is used instead of simple class

    <datacontractmodel dslversion="1.0.0.0" id="d030b2a1-56d2-4754-8044-dbee637f9ccc" implementationtechnology="{b327a38e-00f0-4967-838b-8e8fcc93db30}|WCF|WCF Extension" namespace="http://HCBS.DataTier.Service/DataContracts/v1" projectmappingtable="HCBS.DataTier.Service" xmlns="http://schemas.microsoft.com/dsltools/DataContractDsl"><contracts><datacontract id="761dcc15-7703-4f4b-ade2-5199ed72218d" name="AssessmentDC" namespace="http://HCBS.DataTier.Service/DataContracts/v1" objectextendercontainer="<?xml version="1.0"?> <ObjectExtenderContainer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <ObjectExtenders xsi:type="WCFDataContract" /> </ObjectExtenderContainer>"><datamembers><primitivedatatype collectiontype="" isnullable="false" name="CaseActivityKey" objectextendercontainer="<?xml version="1.0"?> <ObjectExtenderContainer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <ObjectExtenders xsi:type="WCFDataElement"> <IsRequired>false</IsRequired> <Order>0</Order> </ObjectExtenders> </ObjectExtenderContainer>" type="System.Int32"></primitivedatatype><primitivedatatype collectiontype="" isnullable="true" name="PriorityRisk" objectextendercontainer="<?xml version="1.0"?> <ObjectExtenderContainer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <ObjectExtenders xsi:type="WCFDataElement"> <IsRequired>false</IsRequired> <Order>1</Order> </ObjectExtenders> </ObjectExtenderContainer>" type="System.Int32"></primitivedatatype><primitivedatatype collectiontype="" isnullable="true" name="PAHeaderKey" objectextendercontainer="<?xml version="1.0"?> <ObjectExtenderContainer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <ObjectExtenders xsi:type="WCFDataElement"> <IsRequired>false</IsRequired> <Order>2</Order> </ObjectExtenders> </ObjectExtenderContainer>" type="System.Int32"></primitivedatatype><primitivedatatype collectiontype="" isnullable="false" name="CreatedDate" objectextendercontainer="<?xml version="1.0"?> <ObjectExtenderContainer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <ObjectExtenders xsi:type="WCFDataElement"> <IsRequired>false</IsRequired> <Order>3</Order> </ObjectExtenders> </ObjectExtenderContainer>" type="System.DateTime"></primitivedatatype></datamembers> </datacontract> <datacontract id="6105a865-abb3-4111-a4fb-6535847e4b67" name="AssessmentRequestedServiceDC" namespace="http://HCBS.DataTier.Service/DataContracts/v1" objectextendercontainer="<?xml version="1.0"?> <ObjectExtenderContainer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <ObjectExtenders xsi:type="WCFDataContract" /> </ObjectExtenderContainer>"><datacontractcollections><datacontractcollectionmoniker id="23de08bd-1d32-47a8-b88f-945093280414"></datacontractcollectionmoniker></datacontractcollections> <datamembers>
    <?xml version="1.0" encoding="utf-8"?>
    <dataContractModel dslVersion="1.0.0.0" Id="d030b2a1-56d2-4754-8044-dbee637f9ccc" implementationTechnology="{b327a38e-00f0-4967-838b-8e8fcc93db30}|WCF|WCF Extension" projectMappingTable="HCBS.DataTier.Service" namespace="http://HCBS.DataTier.Service/DataContracts/v1" xmlns="http://schemas.microsoft.com/dsltools/DataContractDsl">
      <contracts>
        <dataContract Id="761dcc15-7703-4f4b-ade2-5199ed72218d" objectExtenderContainer="&lt;?xml version=&quot;1.0&quot;?&gt;&#xD;&#xA;&lt;ObjectExtenderContainer xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;&#xD;&#xA;  &lt;ObjectExtenders xsi:type=&quot;WCFDataContract&quot; /&gt;&#xD;&#xA;&lt;/ObjectExtenderContainer&gt;" name="AssessmentDC" namespace="http://HCBS.DataTier.Service/DataContracts/v1">
          <dataMembers>
            <primitiveDataType objectExtenderContainer="&lt;?xml version=&quot;1.0&quot;?&gt;&#xD;&#xA;&lt;ObjectExtenderContainer xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;&#xD;&#xA;  &lt;ObjectExtenders xsi:type=&quot;WCFDataElement&quot;&gt;&#xD;&#xA;    &lt;IsRequired&gt;false&lt;/IsRequired&gt;&#xD;&#xA;    &lt;Order&gt;0&lt;/Order&gt;&#xD;&#xA;  &lt;/ObjectExtenders&gt;&#xD;&#xA;&lt;/ObjectExtenderContainer&gt;" name="CaseActivityKey" collectionType="" isNullable="false" type="System.Int32" />
            <primitiveDataType objectExtenderContainer="&lt;?xml version=&quot;1.0&quot;?&gt;&#xD;&#xA;&lt;ObjectExtenderContainer xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;&#xD;&#xA;  &lt;ObjectExtenders xsi:type=&quot;WCFDataElement&quot;&gt;&#xD;&#xA;    &lt;IsRequired&gt;false&lt;/IsRequired&gt;&#xD;&#xA;    &lt;Order&gt;1&lt;/Order&gt;&#xD;&#xA;  &lt;/ObjectExtenders&gt;&#xD;&#xA;&lt;/ObjectExtenderContainer&gt;" name="PriorityRisk" collectionType="" isNullable="true" type="System.Int32" />
            <primitiveDataType objectExtenderContainer="&lt;?xml version=&quot;1.0&quot;?&gt;&#xD;&#xA;&lt;ObjectExtenderContainer xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;&#xD;&#xA;  &lt;ObjectExtenders xsi:type=&quot;WCFDataElement&quot;&gt;&#xD;&#xA;    &lt;IsRequired&gt;false&lt;/IsRequired&gt;&#xD;&#xA;    &lt;Order&gt;2&lt;/Order&gt;&#xD;&#xA;  &lt;/ObjectExtenders&gt;&#xD;&#xA;&lt;/ObjectExtenderContainer&gt;" name="PAHeaderKey" collectionType="" isNullable="true" type="System.Int32" />
            <primitiveDataType objectExtenderContainer="&lt;?xml version=&quot;1.0&quot;?&gt;&#xD;&#xA;&lt;ObjectExtenderContainer xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;&#xD;&#xA;  &lt;ObjectExtenders xsi:type=&quot;WCFDataElement&quot;&gt;&#xD;&#xA;    &lt;IsRequired&gt;false&lt;/IsRequired&gt;&#xD;&#xA;    &lt;Order&gt;3&lt;/Order&gt;&#xD;&#xA;  &lt;/ObjectExtenders&gt;&#xD;&#xA;&lt;/ObjectExtenderContainer&gt;" name="CreatedDate" collectionType="" isNullable="false" type="System.DateTime" />
          </dataMembers>
        </dataContract>
        <dataContract Id="6105a865-abb3-4111-a4fb-6535847e4b67" objectExtenderContainer="&lt;?xml version=&quot;1.0&quot;?&gt;&#xD;&#xA;&lt;ObjectExtenderContainer xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;&#xD;&#xA;  &lt;ObjectExtenders xsi:type=&quot;WCFDataContract&quot; /&gt;&#xD;&#xA;&lt;/ObjectExtenderContainer&gt;" name="AssessmentRequestedServiceDC" namespace="http://HCBS.DataTier.Service/DataContracts/v1">
          <dataContractCollections>
            <dataContractCollectionMoniker Id="23de08bd-1d32-47a8-b88f-945093280414" />
          </dataContractCollections>
          <dataMembers>

    </datamembers></datacontract></contracts></datacontractmodel>
    Monday, July 23, 2018 2:21 PM

All replies

  • A [datacontract] decorating a class that has been  instanced into an object tells WCF to XML serialize/deserializ the object so that it can be transmitted between the WCF client and services.   There is no harm in sending already formulated XML without the need for a class/object that is XML  serialized/deserialized. 
    • Proposed as answer by kobosh3 Monday, August 6, 2018 12:43 AM
    Monday, July 23, 2018 4:39 PM
  • But can a human write this! it is so complicated ; I have shown you only small part of the file
    Monday, July 23, 2018 6:01 PM
  • hi DA924x  are you saying it has nothing to do with COM or tcp?
    Monday, July 23, 2018 6:04 PM
  • hi DA924x  are you saying it has nothing to do with COM or tcp?

    XML has nothing to do with COM (Component Object Model), which is the predecessor to a .NET object. XML has nothing to do Transmission Control Protocol, which XML can be sent over TCP.

    XML is a universal data language that can be written by a human being  using a text editor and read by a human being.

    https://www.sitepoint.com/really-good-introduction-xml/

    Tuesday, July 24, 2018 1:16 AM
  • Hi kobosh,

    >>But can a human write this! it is so complicated ; I have shown you only small part of the file

    In general, this is not write by human.

    When developing WCF Service, we add "DataContract" to class below:

        [DataContract]
        public class CompositeType
        {
            bool boolValue = true;
            string stringValue = "Hello ";
    
            [DataMember]
            public bool BoolValue
            {
                get { return boolValue; }
                set { boolValue = value; }
            }
    
            [DataMember]
            public string StringValue
            {
                get { return stringValue; }
                set { stringValue = value; }
            }
        }
    

    And, it will generate the XML description when accessing the xsd.

    It will generate the corresponding Model when you generate client proxy by wsdl.

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, July 24, 2018 6:19 AM
  • Hi guys I want to accept all these as answers and move on; I cannot find the way to accept as answer
    Wednesday, August 8, 2018 11:54 PM