使用新命名空间自定义 OData xml

发布于 2024-12-13 19:26:00 字数 3719 浏览 1 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一萌ing 2024-12-20 19:26:00

目前 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文