我正在研究WCF。我有一个网站解决方案,我想在其中使用WCF。当我打电话给" http://---.com:83/Service.svc"出现此错误: ' http://---.com:83/Service.svc/mex'的端点没有与Message MessageVersion绑定。 ' System.ServiceModel.Description.WebHttpBehavior'仅适用于WebHttpBinding或类似的绑定。
我不知道代码中有什么问题! 配置代码:
<?xml version="1.0"?>
<system.web>
<compilation debug="false" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.serviceModel>
<services>
<service name="Service" behaviorConfiguration="serviceBehave">
<endpoint address="mex" binding="mexHttpBinding" behaviorConfiguration="endPointBehav" contract="IService"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="serviceBehave">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="endPointBehav">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
</system.serviceModel>
IService代码:
[ServiceContract]
public interface IService
{
[OperationContract]
String DoWork();
}
Service.cs:
public class Service : IService
{
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "DoWork")]
public string DoWork()
{
return "done!";
}
}
请注意我的解决方案中的IService.cs和Service.cs都位于App_Code文件夹中。在配置文件中没有任何名称空间名称。