Visual studio 2013 &引用;添加服务引用…”;对于OData提要。。。不在Visual Studio中工作

Visual studio 2013 &引用;添加服务引用…”;对于OData提要。。。不在Visual Studio中工作,visual-studio-2013,odata,Visual Studio 2013,Odata,为什么我不能在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:DataServiceVersi

为什么我不能在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数据服务5.5(OData3)”从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.
下载时出错'http://nsuli.com/odata/us/_vti_bin/ListData.svc/$metadata'。
请求失败,HTTP状态为404:未找到。
元数据包含无法解析的引用:'http://nsuli.com/odata/us/'.
内容类型为application/xml;响应消息的charset=utf-8与绑定的内容类型不匹配(application/soap+xml;charset=utf-8)。如果使用自定义编码器,请确保正确实现IsContentTypeSupported方法。响应的前354个字节是:“DefaultImportedSeries\u nUpdate”。
如果服务是在当前解决方案中定义的,请尝试构建解决方案并再次添加服务引用。

这应该是元数据格式问题。以下服务可用于“添加服务引用”。如果可以更改服务端代码,可以将其用作演示。 $metadata

另一方面,OData现在可以使用T4生成客户机代码。你可以参考以下博客: 如果我这样做

metadata = metadata.Replace(
    "xmlns:edmx=\"schemas.microsoft.com/ado/2009/11/edmx\"",
    "xmlns:edmx=\"schemas.microsoft.com/ado/2007/06/edmx\""
) 

在我的$metadata文档中,然后“添加服务引用”就可以了……。

谢谢。我的元数据是使用ODataLib 5.6.1库生成的(var eModel=new Microsoft.Data.Edm.library.EdmModel();……WriteMetadataDocument()等)。我的元数据与上述元数据之间的区别在于,我的元数据以开头,而另一个元数据以开头,请参见后续问题: