0
我正在使用WCF数据服务。使用新命名空间自定义OData xml
在我的OData服务的实体默认饲料属性是
<feed xml:base="http://localhost:54527/DataModel.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
如何添加自己的名字空间这份名单在饲料财产?
我试图让我的odata服务GeoRSS兼容,我已经添加了一些EntityPropertyMappingAttribute的使数据兼容,但它没有被我们正在使用的工具识别。
现在它生产的:
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<feed xml:base="http://localhost:54527/DataModel.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
<title type="text">Collars</title>
<id>http://localhost:54527/DataModel.svc/Collars</id>
<updated>2011-11-07T09:23:05Z</updated>
<link rel="self" title="Collars" href="Collars" />
<entry>
<id>http://localhost:54527/DataModel.svc/Collars(HOLEID='ABL001',PROJECTCODE='ACA')</id>
<title type="text"></title>
<updated>2011-11-07T09:23:05Z</updated>
<author>
<name />
</author>
<link rel="edit" title="Collar" href="Collars(HOLEID='ABL001',PROJECTCODE='ACA')" />
<category term="Neo.Collar" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<content type="application/xml">
<m:properties>
<d:HOLEID>ABL001</d:HOLEID>
<d:PROJECTCODE>ACA</d:PROJECTCODE>
<d:TENEMENTID>5853</d:TENEMENTID>
<d:LAT>116.49531406</d:LAT>
<d:LONG>-21.65159678</d:LONG>
</m:properties>
</content>
<geo:lat xmlns:geo="http://www.georss.org/georss">116.49531406</geo:lat>
<geo:long xmlns:geo="http://www.georss.org/georss">-21.65159678</geo:long>
</entry>
但我宁愿有地理命名了顶部:
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<feed xml:base="http://localhost:54527/DataModel.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom"
xmlns:geo="http://www.georss.org/georss">
<title type="text">Collars</title>
<id>http://localhost:54527/DataModel.svc/Collars</id>
<updated>2011-11-07T09:23:05Z</updated>
<link rel="self" title="Collars" href="Collars" />
<entry>
<id>http://localhost:54527/DataModel.svc/Collars(HOLEID='ABL001',PROJECTCODE='ACA')</id>
<title type="text"></title>
<updated>2011-11-07T09:23:05Z</updated>
<author>
<name />
</author>
<link rel="edit" title="Collar" href="Collars(HOLEID='ABL001',PROJECTCODE='ACA')" />
<category term="Neo.Collar" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<content type="application/xml">
<m:properties>
<d:HOLEID>ABL001</d:HOLEID>
<d:PROJECTCODE>ACA</d:PROJECTCODE>
<d:TENEMENTID>5853</d:TENEMENTID>
<d:LAT>116.49531406</d:LAT>
<d:LONG>-21.65159678</d:LONG>
</m:properties>
</content>
<geo:lat>116.49531406</geo:lat>
<geo:long>-21.65159678</geo:long>
</entry>
我可能会对此完全错误的方式。 谢谢。
你能澄清你为什么要添加命名空间吗?只有在使用了名称空间的情况下才有意义,这意味着要更改序列化,并且在这种情况下,所有使用的名称空间都将被自动包含。 –
增加了一些我想要实现的更多细节。 – Sigh
举例来说,这个OData源代码完全是我想要实现的关于地理名称空间的命名空间,它可以被我们正在使用的geo rss工具使用。 http://www.commuterapi.com/Wiki/developer-resources和http://transit.cloudapp.net/DevTransitODataService.svc/Stops – Sigh