为什么我不能在Visual Studio中将“添加服务引用”添加到此odata端点:
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx" Version="3.0">
<edmx:DataServices xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="3.0">
<Schema xmlns="http://schemas.microsoft.com/ado/2009/11/edm" Namespace="nsuli_com">
<EntityType Name="EntityType0">
<Key>
<PropertyRef Name="DateS"/>
</Key>
<Property Name="DateS" Type="Edm.DateTime" Nullable="false"/>
</EntityType>
<EntityContainer Name="us">
<EntitySet Name="ImportedSeries_NFPDates" EntityType="nsuli_com.EntityType0"/>
</EntityContainer>
</Schema>
</edmx:DataServices>
它使用驱动程序“WCF Data Services 5.5(OData 3)”从LINQPad 4开始工作......但“添加服务引用...”显示错误:
There was an error downloading 'http://nsuli.com/odata/us/_vti_bin/ListData.svc/$metadata'.
The request failed with HTTP status 404: Not Found.
Metadata contains a reference that cannot be resolved: 'http://nsuli.com/odata/us/'.
The content type application/xml;charset=utf-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 354 bytes of the response were: '<?xml version="1.0" encoding="utf-8"?><service xml:base="http://nsuli.com/odata/us/" xmlns="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom"><workspace><atom:title type="text">Default</atom:title><collection href="ImportedSeries_NFPDates"><atom:title type="text">ImportedSeries_NFPDates</atom:title></collection></workspace></service>'.
If the service is defined in the current solution, try building the solution and adding the service reference again.
答案 0 :(得分:1)
应该是元数据格式问题。以下服务可用于&#34;添加服务参考&#34;。如果您可以更改服务端代码,则可以将其用作演示。 http://services.odata.org/V3/OData/OData.svc/ $元数据
另一方面,OData现在可以使用T4生成客户端代码。你可以参考以下博客: http://blogs.msdn.com/b/odatateam/archive/2014/03/11/how-to-use-odata-client-code-generator-to-generate-client-side-proxy-class.aspx
答案 1 :(得分:0)
如果我这样做
metadata = metadata.Replace(
"xmlns:edmx=\"schemas.microsoft.com/ado/2009/11/edmx\"",
"xmlns:edmx=\"schemas.microsoft.com/ado/2007/06/edmx\""
)
在我的元数据文档中,然后&#34;添加服务参考&#34;工作得很好............