2013-03-14 69 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

希律一切都亮了起來,並出現了大家歡欣鼓舞。