在此服务主机的已实施合同中未找到合同

时间:2012-04-07 09:32:49

标签: wcf mono opensuse wcf-configuration

我收到了标题中提到的错误,但不确定我到底做错了什么。我在openSUSE上运行Mono 2.10.6。只有当我尝试浏览到WCF服务时才会出现此问题(网页加载正常)。

服务代码是:

namespace CyberLane
{
    [ServiceContract]
    public class DataServices// : IDataServices
    {
        [OperationContract]
        public TweetDTO[] GetLatestTweets()
        {
            return MasterRepository.GetTweets().Select(x => new TweetDTO(x)).ToArray();
        }
    }
}

我的Web.config有以下内容:

<system.serviceModel>
    <behaviors>
        <endpointBehaviors>
            <behavior name="CyberLane.DataServicesAspNetAjaxBehavior">
                 <enableWebScript />
            </behavior>
        </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <services>
        <service name="CyberLane.DataServices">
            <endpoint address="" behaviorConfiguration="CyberLane.DataServicesAspNetAjaxBehavior" binding="webHttpBinding" contract="CyberLane.DataServices" />
        </service>
    </services>
</system.serviceModel>

如果您需要更多信息,请询问我,我将非常乐意与您分享!这让我疯狂了几个星期了。

1 个答案:

答案 0 :(得分:1)

首先,最佳实践和常用方法是使用ServiceModel属性来装饰IDataServices(接口),而不是实现它的类。

相关问题