如何从 Java 与 OData 交互?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2403359/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I interact with OData from Java?
提问by
OData is Microsoft's repackaging of its Astoria (now WCF Data Services) RESTful query/update protocol. If I want to use Java to create an OData compatible data source, how do I do that? Similarly, if I want to consume an OData data source from Java, how do I do that?
OData 是微软对其 Astoria(现在的 WCF 数据服务)RESTful 查询/更新协议的重新打包。如果我想使用 Java 创建 OData 兼容的数据源,我该怎么做?同样,如果我想从 Java 使用 OData 数据源,我该怎么做?
Partial answer below.
下面部分回答。
The OData website suggests that Restlet supports OData. Restlet's API documentation mentions the org.restlet.ext.odata package.
OData 网站建议 Restlet 支持 OData。Restlet 的 API 文档提到了 org.restlet.ext.odata 包。
www.restlet.org/
www.restlet.org/
www.restlet.org/documentation/snapshot/jee/ext/org/restlet/ext/odata/package-summary.html
www.restlet.org/documentation/snapshot/jee/ext/org/restlet/ext/odata/package-summary.html
Is this the only answer? Are there blog posts on doing this integration?
这是唯一的答案吗?是否有关于进行这种集成的博客文章?
回答by Darrel Miller
Any Java library that can consume an Atom feed will be able to read an OData source. Any Java library that can perform the Atom pub protocol will be able to update an OData service.
任何可以使用 Atom 提要的 Java 库都可以读取 OData 源。任何可以执行 Atom pub 协议的 Java 库都可以更新 OData 服务。
What you will not be able to do out of the box is perform queries and access the EDM properties. Depending on how loosely coupled you need to be this will either be really easy to do or damn difficult. If you can survive coupling your client to the service then it should be pretty easy with any XML parser to pull the data out of the OData entry.
您无法立即执行查询并访问 EDM 属性。根据您需要的松散耦合程度,这将很容易做到,或者非常困难。如果您可以将客户端与服务耦合在一起,那么使用任何 XML 解析器将数据从 OData 条目中提取出来应该很容易。
回答by Dirk Vollmar
There is a Microsoft blog post with various pointers to OData interoperability resources:
有一篇 Microsoft 博客文章包含指向 OData 互操作性资源的各种指针:
OData interoperability with .NET, Java, PHP, iPhone and more
回答by Alex James
See this: http://blog.noelios.com/2010/03/15/restlet-supports-odata-the-open-data-protocol/and this: http://wiki.restlet.org/docs_2.0/13-restlet/28-restlet/287-restlet/288-restlet.html
看到这个:http: //blog.noelios.com/2010/03/15/restlet-supports-odata-the-open-data-protocol/和这个:http: //wiki.restlet.org/docs_2.0/ 13-restlet/28-restlet/287-restlet/288-restlet.html
Also there is a growing list of information on OData here: http://odata.org/developers/odata-sdk
这里还有越来越多关于 OData 的信息列表:http: //odata.org/developers/odata-sdk
hope this helps
希望这可以帮助
Alex
亚历克斯
回答by Carl H?rberg
回答by Krutik
There is a olingo library in java which can be used for RESTful communication with Odata protocol.
Java 中有一个 olingo 库,可用于与 Odata 协议进行 RESTful 通信。
you can refer the following link for the reference: https://olingo.apache.org/doc/odata4/index.html
您可以参考以下链接进行参考:https: //olingo.apache.org/doc/odata4/index.html
You can find the source code for sample project too from the above link.
您也可以从上面的链接中找到示例项目的源代码。