用XML而不是类建模 [英] Model in XML instead of class

查看:49
本文介绍了用XML而不是类建模的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在处理我从之前的开发人员那里得到的代码。它是wcf服务,我看到xml文件,我期望在模块部分中的类。 xml看起来部分就像这个。我想知道使用xml而不是普通数据合约
类的目的是什么?我试图谷歌,我发现有时需要与COM对象进行通信。我不明白这一部分。我的意思是使用xml而不是简单类的情况

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

<?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>

推荐答案

[datacontract]装饰已经过的课程instanced到一个对象告诉WCF XML序列化/ de serializ 该对象,以便它可以在WCF客户端和服务之间传输。 &NBSP;
对于发送已经公式化的XML没有任何害处,而不需要XML的类/对象  serialized / de 序列化。 
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. 


这篇关于用XML而不是类建模的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆