如何从元数据中找到OData版本 [英] How to find OData version from metadata

查看:168
本文介绍了如何从元数据中找到OData版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以访问OData服务.现在,我需要找到该服务的OData版本. $ metadata中有版本属性.但是我不知道要接哪一个.

I have access to a OData service. Now I need find the OData version of the service. There are version attributes in $metadata. But I don't know which one to pickup.

我是否需要从<edmx:Edmx Version="1.0">DataServiceVersion HTTP标头

例如,

  1. http://services.odata.org /v4/%28S%28cy2mvwlr34teasunjfqlhlyg%29%29/TripPinServiceRW/ $ metadata返回版本为4.0,但响应中不包含DataServiceVersion.但它具有OData版本 HTTP标头

  1. http://services.odata.org/v4/%28S%28cy2mvwlr34teasunjfqlhlyg%29%29/TripPinServiceRW/$metadata returns Version as 4.0 but does not contain DataServiceVersion in the response. But it has OData Version HTTP header

http://services.odata.org/OData/OData.svc/ $ metadata返回Version为1.0,DataServiceVersion为3.0.它不包含OData版本HTTP标头.但是它具有DataServiceVersion HTTP标头

http://services.odata.org/OData/OData.svc/$metadata returns Version as 1.0 and DataServiceVersion as 3.0. This does not contain OData Version HTTP header. But it has DataServiceVersion HTTP header

http://services.odata.org/V3/Northwind/Northwind.svc/ $ metadata返回版本为1.0,数据服务版本为1.0.它不包含OData版本HTTP标头.但是它具有DataServiceVersion HTTP标头

http://services.odata.org/V3/Northwind/Northwind.svc/$metadata returns Version as 1.0 and DataServiceVersion as 1.0. This does not contain OData Version HTTP header. But it has DataServiceVersion HTTP header

请让我知道如何使用服务元数据找到OData版本?还是有其他方法可以找到它?

Please let me know how can I find the OData version using service metadata? Or is there any other way to find it?

推荐答案

对于每个示例,按照OASIS标准:

According to OASIS standard, for each example:

  1. v4现在需要在对于示例2和3,您需要阅读

    For examples 2 and 3, you'll want to read this note about versioning which states:

    OData协议支持版本控制方案,以使服务能够公开新功能和格式版本,而不会破坏与旧客户端的兼容性.

    The OData protocol supports a versioning scheme for enabling services to expose new features and format versions without breaking compatibility with older clients.

    OData请求和响应可以根据DataServiceVersion标头进行版本控制.

    OData requests and responses MAY be versioned according to The DataServiceVersion Header.

    OData客户端应该使用MinDataServiceVersion和MaxDataServiceVersion标头,以指定可接受的响应DataServiceVersions的范围.

    An OData client SHOULD use the MinDataServiceVersion and MaxDataServiceVersion headers in order to specify the range of acceptable response DataServiceVersions.

    服务应以服务支持的最大版本(小于或等于指定的MaxDataServiceVersion)进行响应.

    The service SHOULD respond with the maximum version supported by the service that is less than or equal to the specified MaxDataServiceVersion.

    您会注意到,就OData实现而言,事情有点像狂野的西部(许多 MAY SHOULD 就上述示例如何适合此规范而言:

    You'lll notice things are kind of the wild wild west in terms of OData implementations (a lot of MAY's and SHOULD's. In terms of how the examples above fit this specification:

    1. v2指定Version必须为1.0,但DataServiceVersion必须为Odata协议的版本使用该服务所需的,并且为['1.0','2.0','3.0']之一, 按规范... li>
    2. 该服务声称支持OData客户端v1-v3.因此,客户可以使用自己的 DataServiceVersion (1.02.03.0),仍然会收到符合给定版本标准的响应.
    1. v2 specifies that the Version must be 1.0, but that the DataServiceVersion must be the version of OData protocol required to consume the service, and be one of ['1.0','2.0','3.0'], per spec.
    2. This service is claiming to support OData clients v1-v3. So a client could submit a request with their own DataServiceVersion of 1.0, 2.0 or 3.0 and still receive a response that fits the standard for the given version.

    因此,根据要连接的服务,您将需要进行不同的检查.也许像这样的流:

    So, depending on what service you're connecting to, you'll want to check differently. Maybe a flow like:

    1. 检查<edmx:Edmx />版本是否为4.0(您知道OData v4)
    2. 否则,请检查<edmx:DataServices />是否具有MaxDataServiceVersion属性(您现在具有最高可用的OData版本)
    3. 否则,检查<edmx:DataServices />是否具有MinDataServiceVersion属性(您现在具有受支持的最低OData版本)
    4. 否则,请检查<edmx:DataServices />是否具有DataServiceVersion属性(您现在具有受支持的最低OData版本)
    1. Check if <edmx:Edmx /> version is 4.0 (you know OData v4)
    2. Else, check if <edmx:DataServices /> has a MaxDataServiceVersion property (you now have highest available OData version)
    3. Else, check if <edmx:DataServices /> has a MinDataServiceVersion property (you now have minimum supported OData version)
    4. Else, check if <edmx:DataServices /> has a DataServiceVersion property (you now have minimum supported OData version)

    这篇关于如何从元数据中找到OData版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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