在Microsoft Dynamics导航2016中使用Odata Web服务为特定集合或实体获取$ metadata [英] Fetching $metadata for a specific collection or entity with Odata web services in Microsoft Dynamics NAV 2016

查看:111
本文介绍了在Microsoft Dynamics导航2016中使用Odata Web服务为特定集合或实体获取$ metadata的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为集成项目的一部分,我需要一个PHP网站才能读取和写入Microsoft Dynamics导航2016的Odata服务.

As part of an integration project, I need a PHP website to be able to both read from and write to Microsoft Dynamics NAV 2016's Odata services.

Microsoft Dynamics导航2016使用

Microsoft Dynamics NAV 2016 uses the Odata v3 standard.

现在,让我们以我的customer服务为例.

Now, let's take my customer service as an example.

使用以下格式的链接来获取我的customer实体集合的概述很好:

Fetching an overview of my collection of customer entities works fine, using a link with the following format :

https://<Server>:<WebServicePort>/<ServerInstance>/OData/Company(\'<CompanyName>\')/customer

获取单个实体

使用具有以下格式的链接,可以基于id获取单个customer实体,效果很好:

Fetching a single entity

Fetching a single customer entity based on id works fine, using a link with the following format :

https://<Server>:<WebServicePort>/<ServerInstance>/OData/Company(\'<CompanyName>\')/customer(\'<Id>\')

获取全局元数据

使用以下格式的链接来获得我所有服务的$metadata概述很好(尽管它缺少Json支持):

Fetching the global metadata

Getting an overview of the $metadata for all of my services works fine (although it's lacking Json support), using a link with the following format :

https://<Server>:<WebServicePort>/<ServerInstance>/OData/$metadata

获取特定于集合的元数据

现在,基于两个

Fetching collection-specific metadata

Now, based on both the Odata v3 specs and the value of the odata.metadata property of my customer overview service, I would expect to be able to get an overview of the $metadata of the customer entity, using a link with the following format :

https://<Server>:<WebServicePort>/<ServerInstance>/OData/$metadata#customer

这不符合预期.请参阅下面的The issue小节.

This doesn't work as expected. See sub-section The issue below.

同样,基于两个

Similarly, based on both the Odata v3 specs and the value of the odata.metadata property of my dataset when retrieving a single customer, I would expect to be able to get an overview of the $metadata of a single field of the customer entity, using a link with this format :

https://<Server>:<WebServicePort>/<ServerInstance>/OData/$metadata#customer/@<FieldName>

这不符合预期.请参阅下面的The issue小节.

This doesn't work as expected. See sub-section The issue below.

由于某些原因,$metadata之后的所有内容似乎都将被忽略.这意味着最后三个URL给我的输出完全相同,这不是我期望的.

For some reason, everything following $metadata appears to be ignored. This means that the last three URLs give me the exact same output, which is not what I expected.

  • 就像我在上文The context部分的Fetching collection-specific metadataFetching entity-specific metadata小节中尝试的那样,是否可以仅获取一个集合或实体的元数据?
  • 如果是,我在这里做错了什么?我想念什么?
  • Is it possible to fetch the metadata of just one collection or entity, as I'm trying in sub-sections Fetching collection-specific metadata and Fetching entity-specific metadata of my The context section hereabove?
  • If yes, what I doing wrong here? What am I missing?

推荐答案

@xuzhg 在注释中建议,并由Github指出,例如> 支持元数据作为服务(#181) ,看来Odata $metadata并不是真正的动态服务.相反,它只是一个XML文件.

As @xuzhg suggested in the comments and as is indicated by Github issues like Support Metadata as a service (#181), it appears that the Odata $metadata are not really a dynamic service. Instead, it's just a single XML file.

这不仅解释了为什么在格式为https://<Server>:<WebServicePort>/<ServerInstance>/OData/$metadata#...的链接中$ metadata之后的任何内容都被忽略,还解释了为什么它仅支持XML而不支持Json(与实际的Odata服务不同)的原因.

This explains not only why anything after $metadata is ignored in links of format https://<Server>:<WebServicePort>/<ServerInstance>/OData/$metadata#..., but also why it only supports XML, and not Json (unlike actual Odata services).

这篇关于在Microsoft Dynamics导航2016中使用Odata Web服务为特定集合或实体获取$ metadata的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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