使用新命名空间自定义 OData xml
我正在使用 WCF 数据服务。
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>
我可能会以完全错误的方式处理这个问题。 谢谢。
I'm using WCF Data services.
The default feed property for an entity in my OData service is
<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">
How can I add my own name spaces to this list in the feed property?
I'm trying to make my odata service GeoRSS compatible, I've added some EntityPropertyMappingAttribute's to make the data compatible, but it isn't being recognised by the tool we're using.
Right now it's producing this:
<?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>
But I would rather have the geo namespace up the top:
<?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>
I might be going about this completely the wrong way.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
目前 WCF 数据服务中无法执行此操作。实体属性映射在本地工作(在它映射到的元素上),它无法指定应预先声明某些名称空间。
Currently there's no way in WCF Data Services to do this. The Entity Property Mapping works locally (on the element it maps to), there's no ability for it to specify that some namespaces should be declared up front.