我想讓我的第一個WCF服務。 我有問題 - 我寫了一個結構,一個類和幾個方法。 我的服務合同是這樣的:wcf服務不工作 - 未能添加服務
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace WebshopReports
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IReports" in both code and config file together.
[ServiceContract]
public interface IReports
{
[OperationContract]
List<Category> getReportCategories(string dir);
[OperationContract]
List<CReport> getReportList(Category category);
}
}
當我使用測試客戶端在Visual Studio中運行它,我得到如下:
無法添加服務。服務元數據可能無法訪問。使 確定您的服務正在運行並展示元數據。
我確定它與我的web.config文件有關。在下面。是否有人可以幫助我,我不能確定如何配置web.config中:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
奇怪的是,如果我改變從一類CReport一個struct,它會工作。
也許我看着我的解決方案錯誤的方式。我想創建一個服務來接受參數,運行水晶報表並返回數據。 WSDL服務是解決這個問題的最佳方法嗎? – Lock 2011-12-14 00:56:19