开发者

Can't Add Reference to My WCF Data Service

开发者 https://www.devze.com 2023-03-07 16:40 出处:网络
I have a WCF Data Service. I can browse to it OK 开发者_如何学JAVAin 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

I have a WCF Data Service. I can browse to it OK 开发者_如何学JAVAin 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

The document at the url http://localhost/Services/OData/Repository/ was not recognized as a known document type.

When I browse to my service at http://localhost/Services/OData/Repository/, I see

<?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.

I suspect this has to do with how I'm adding my OData service, but I'm not sure. I don't have an svc file. Instead I'm adding a route to my RouteTable as follows:

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...

Any ideas?

Thanks.


When adding a service reference, what you want is the the $metadata end point:

http://localhost/Services/OData/Repository/$metadata


Have you recently upgraded to another version of Windows?

If so, you need to run

ServiceModelReg -i

You can find that in your %WINDIR%\Microsoft.NET\Framework\version\Windows Communication Foundation folder.

0

精彩评论

暂无评论...
验证码 换一张
取 消