0

使用 VS2012 并从 SL 业务应用程序项目开始,我添加了一个 EF 模型 Model1,删除了 tt 文件,将代码生成更改为默认并构建了项目。然后我添加了带有各种表的 DomainService1。未选择 OData。

启动应用程序,它似乎有一个可用的服务:

在此处输入图像描述

但是如果我们单击 url,我们希望看到 XML,但它不起作用。附加 ?wsdl 应该会导致 XML 被发送到浏览器,但我只是得到了插图页面。按照本页的建议使用 svcutil 进行尝试会产生以下结果:

Microsoft (R) Service Model Metadata Tool [Microsoft (R) Windows (R) Communication 
Foundation, Version 4.0.30319.17929] Copyright (c) Microsoft Corporation.  
All rights reserved.

Attempting to download metadata from 'http://localhost:57880/Ria1-Web-DomainService1.sv
c?wsdl' using WS-Metadata Exchange or DISCO. Generating files...     
Warning: No code was generated. If you were trying to generate a client, this could be 
because the metadata documents did not contain any valid contracts or services or 
because all contracts/services were discovered to exist in /reference assemblies. 
Verify that you passed all the metadata documents to the tool.

Warning: If you would like to generate data contracts from schemas make sure to use
the /dataContractOnly option.

这似乎表明 MEX 端点的设计不正确,所以我的 WCF 书籍出来了,但他们认为应该包含的<system.serviceModel>内容与实际存在的内容之间没有关联:

  <system.serviceModel>
    <serviceHostingEnvironment 
      aspNetCompatibilityEnabled="true"
      multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

我需要在配置中添加什么来公开元数据?

4

1 回答 1

0

在准备这个问题时,我想知道当您指定 OData 时配置会发生什么。事实证明这是一个正确的问题。你得到这个:

  <system.serviceModel>
    <serviceHostingEnvironment 
      aspNetCompatibilityEnabled="true"
      multipleSiteBindingsEnabled="true" />
    <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>

  </system.serviceModel>

这给了我更多的搜索词。结合来自各种来源的信息导致了这一点:

<add name="Soap" 
     type="Microsoft.ServiceModel.DomainServices.Hosting.SoapXmlEndpointFactory, 
     Microsoft.ServiceModel.DomainServices.Hosting, 
     Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

在我添加对此的引用之前,它完全无法工作:

Microsoft.ServiceModel.DomainServices.Hosting.EndPoints

于是,一切都亮了起来,大家欢欣鼓舞。

于 2013-03-14T13:50:26.377 回答