2013-03-14 103 views
0

使用VS2012并从SL商业应用项目开始,我添加了 EF模型Model1,删除了tt文件,将代码gen更改为Default并构建了项目。然后我添加了DomainService1和各种表格。未选择OData。如何使用SL/RIA作为WCF

启动应用程序似乎有可用的服务:

enter image description here

但是,如果我们点击链接,我们希望看到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> 

我需要什么添加到config来公开元数据?

回答

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

希律一切都亮了起来,并出现了大家欢欣鼓舞。