Visual Studio OData“添加服务引用”代码失败

时间:2014-03-14 14:24:15

标签: c# web-services odata data.gov

This data.gov website为OData数据导出提供了使用链接http://data.cms.gov/OData.svc/97k6-zzx3

的说明

https://data.cms.gov/Medicare/Inpatient-Prospective-Payment-System-IPPS-Provider/97k6-zzx3 screenshot

(在Nugeting Install-Package Microsoft.Data.Services.Client版本5.6.1之后)我尝试在Visual Studio 2012或Visual Studio 2013中使用“添加服务引用”的完整链接到我的C#项目,我得到There was an error downloading 'http://data.cms.gov/OData.svc/97k6-zzx3/_vti_bin/ListData.svc/$metadata'. The request failed with HTTP status 404: Not Found. ...

Visual Studio error message 1

如果我将URL截断为http://data.cms.gov/OData.svc,那么我会更进一步,但仍然是错误The custom tool 'DataServicesCoreClientGenerator' failed. Data service client code-generation failed: Schema specified is not valid. Errors: ... The 'Name' attribute is invalid - the value '97k6-zzx3' is invalid according to its datatype(我想,因为C#标识符不能以数字开头)

Visual Studio error message 2

这是data.cms.gov或Visual Studio(等)的错误吗?有没有紧密的解决方法?

谢谢!

1 个答案:

答案 0 :(得分:4)

尝试使用https://data.cms.gov/OData.svc/$metadata。代码生成需要元数据,上面的URL将提供。

网址https://data.cms.gov/OData.svc是服务文档,而不是元数据。