![](/img/trans.png)
[英]Odata ClientEntity Error - Expected OData Entity, found EntitySet
[英]Getting the count of entries in entitySet in OData using java
以下链接返回客户实体集的条目数http://services.odata.org/Northwind/Northwind.svc/Customers/ $count
如何使用java获取这个数字?
URL url = new URL("http://services.odata.org/Northwind/Northwind.svc/Customers/$count");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET")
在此之后如何编码以将条目计数作为整数?
您需要从HttpURLConnection
流中读取数据,例如
BufferedReader in = new BufferedReader(new InputStreamReader(
conn.getInputStream()));
String count;
while ((count = in.readLine()) != null)
//this will print the count in count variable
System.out.println(count);
in.close();
}
注意:您必须在将请求写入HttpURLConnection
的输出流后执行此操作。 这显然意味着您将请求数据写入连接的输出流并从连接的输入流读取响应数据
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.