0
votes

I've created a new Silverlight application, so I have a web project called "SilverlightOnLineChess.Web" and the Silverlight app called "SilverlightOnlineChess.Client". In this solution I've created a new WCF RIA Services class library called "SilverlightOnlineChess.Data", and in doing so it creates the associated web project called "SilverlightOnlineChess.Data.Web". I've created the necessary Entity Data Model and the domain service classes in the "SilverlightOnlineChess.Data.Web" project and made sure I checked the "Expose OData endpoint".

Everything works fine and dandy to view data via the app. However, if I try to hit the url to see what the OData brings back as in: "http://localhost:49771/SilverlightOnlineChess-Data-Web-OnlineChessService.svc/OData/" it doesn't know what this url is. It only works if I create the services and entity model in the main web project "SilverlightOnLineChess.Web" and not the "SilverlightOnLineChess.Data.Web".

So now if I enter the url as in:

"http://localhost:49771/SilverlightOnlineChess-Web-OnlineChessService.svc/OData/", it brings back the metadata.

Any ideas?

2

2 Answers

0
votes

The URL of the Service occurs as follows:

Namespace + typename for the domain service with dots replaced by dashes followed by .svc/OData/.

After this you need to expose queries to OData by adding

[Query(IsDefault = true)]

above your queries you want to expose.

0
votes

To expose an OData endpoint, you need to make sure you have the following in your web.Config:

<system.serviceModel>
    <domainServices>
      <endpoints>
        <add name="OData" type="System.ServiceModel.DomainServices.Hosting.ODataEndpointFactory, System.ServiceModel.DomainServices.Hosting.OData, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      </endpoints>
    </domainServices>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />    
  </system.serviceModel>

You also need to make sure you are referening the following DLLs:

System.ServiceModel.DomainServices.Hosting.OData C:\Program Files\Microsoft SDKs\RIA Services\v1.0\Libraries\Server\System.ServiceModel.DomainServices.Hosting.OData.dll

You can make sure you're looking for the right URL to your OData service by looking in your client-side project with Show All Files selected. Go to Generated_Code\ProjectName.Web.g.cs. Do a find for Service.svc. That will be the root URI of your OData service. If you put your domain service under a Service folder it will be Service/YourServiceName.svc/OData/.