[英]Can't Add Reference to My WCF Data Service
I have a WCF Data Service. 我有一个WCF数据服务。 I can browse to it OK in my browser and I can make queries to it successfully via the URL...but I can't add a Service Reference to it, and I can't add it to OData Explorer...it just throws an error
我可以在我的浏览器中浏览它,我可以通过URL成功查询...但我无法添加服务引用,我无法将其添加到OData Explorer ...它只是抛出错误
The document at the url http://localhost/Services/OData/Repository/ was not recognized as a known document type.
url http:// localhost / Services / OData / Repository /上的文档未被识别为已知文档类型。
When I browse to my service at http://localhost/Services/OData/Repository/
, I see 当我在
http://localhost/Services/OData/Repository/
浏览我的服务时,我明白了
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<service xml:base="http://localhost/Services/OData/Repository/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns="http://www.w3.org/2007/app">
<workspace>
<atom:title>Default</atom:title>
<collection href="Contacts">
<atom:title>Contacts</atom:title>
</collection>
</workspace>
</service>
Which is exactly what I would expect and want. 这正是我期望和想要的。 And if I go to
http://localhost/Services/OData/Repository/Contacts
, I get my results of Contacts returned successfully. 如果我转到
http://localhost/Services/OData/Repository/Contacts
,我会成功返回Contacts的结果。
I suspect this has to do with how I'm adding my OData service, but I'm not sure. 我怀疑这与我如何添加我的OData服务有关,但我不确定。 I don't have an svc file.
我没有svc文件。 Instead I'm adding a route to my RouteTable as follows:
相反,我正在为RouteTable添加一条路线,如下所示:
RouteTable.Routes.Add(new ServiceRoute("Services/OData/Repository",
new DataServiceHostFactory(),
typeof(IMyRepository));
I do have a clientaccesspolicy.xml file, but that shouldn't matter since this is localhost... 我有一个clientaccesspolicy.xml文件,但这不应该重要,因为这是localhost ...
Any ideas? 有任何想法吗?
Thanks. 谢谢。
When adding a service reference, what you want is the the $metadata end point: 添加服务引用时,您想要的是$ metadata端点:
http://localhost/Services/OData/Repository/ $metadata http:// localhost / Services / OData / Repository / $ metadata
Have you recently upgraded to another version of Windows? 您最近是否已升级到其他版本的Windows?
If so, you need to run 如果是这样,你需要运行
ServiceModelReg -i
You can find that in your %WINDIR%\\Microsoft.NET\\Framework\\version\\Windows Communication Foundation folder. 您可以在%WINDIR%\\ Microsoft.NET \\ Framework \\ version \\ Windows Communication Foundation文件夹中找到它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.