Can't discover the service following Walkthrough: Binding WPF Controls to a WCF Data Service

僤鯓⒐⒋嵵緔 提交于 2019-12-11 19:03:40

问题


I'm following the Walkthrough: Binding WPF Controls to a WCF Data Service

But when I try to Discover the service I get an error saying that there was an error downloading metadata from the address

What could it be?

EDIT:

It basically creates an ASP NET Web App, adds an ADO Nen Entity Model, Adds a WCF Data Service, adds a WPF App to the solution, and tries to add a new data source from the service, the Add Service Reference appears, and it's there where the error appears.


回答1:


Simply added this to the ServiceModel configuration in App.config

  <services>
      <service name="AdventureWorksService"
               behaviorConfiguration="metadataSupport">
          <endpoint
              address="http://localhost:12141/AdventureWorksService/mex"
              binding="mexHttpBinding"
              contract="IMetadataExchange"
          />
      </service>
  </services>
  <behaviors>
      <serviceBehaviors>
          <behavior name="metadataSupport">
              <serviceMetadata/>
          </behavior>
      </serviceBehaviors>
  </behaviors>    



回答2:


My system spec:

  • Windows 7 x64
  • MS SQL Server 2014
  • VS 2015 Community Ed.
  • .net Framework 4.6.2

I'm doing the same walkthrough and have passed this error by following this (https://www.codeproject.com/Articles/1087982/Create-a-WCF-DataService-in-Visual-Studio?display=Print)

Changed parts in italics

Do the change below in the 'Create the service' and 'Configure the service' part of the walkthrough.

The relevant parts from the CodeProject article are Step 11: Add the entity framework provider for OData via nugget command line.

PM> Install-Package Microsoft.OData.EntityFrameworkProvider -Pre

and Step 12: Edit the AdventureWorksService.svc file and:

  • Add the using statement for System.Data.Services.Providers
  • Change inheritance from DataService to EntityFrameworkDataService
  • Change the to be the name of your entity model in my case AdventureWorks2014Entities

Optionally:

  • Set the access rules for your entity names. Use the star symbol to mean all entities.
  • Set the UseVerboseErrors property in order to see proper feedback of errors.
using System.Data.Services.Providers;

namespace AdventureWorksService
{
    public class AdventureWorksService : EntityFrameworkDataService<AdventureWorks2014Entities>
    {
        // This method is called only once to initialize service-wide policies.
        public static void InitializeService(DataServiceConfiguration config)
        {
            // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
            // Examples:
            // config.SetEntitySetAccessRule("MyEntityset", EntitySetRights.AllRead);
            // config.SetServiceOperationAccessRule("MyServiceOperation", ServiceOperationRights.All);
            config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
            config.SetEntitySetAccessRule("SalesOrderHeaders", EntitySetRights.All);
            config.UseVerboseErrors = true;
        }
    }
}

However, now I'm stuck at 'Define the user interface of the window' of the walkthrough :(

Edit 1: Following the answer here, I managed to complete the walkthrough.

Sryn



来源:https://stackoverflow.com/questions/22818525/cant-discover-the-service-following-walkthrough-binding-wpf-controls-to-a-wcf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!