找不到WCF Resful服务错误方法

时间:2016-09-09 12:13:57

标签: c# .net-4.5 wcf-rest

我在WCF Restful服务上遇到错误。

我正在传递网址= http://localhost:16679/SayHelloService.svc/SayHelloMessage

 [ServiceContract]
public interface ISayHelloService
{
    [OperationContract]
    [WebInvoke(Method ="Get", 
               UriTemplate = "/SayHelloMessage", 
               RequestFormat =WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml,
               BodyStyle =WebMessageBodyStyle.Wrapped)]
    string SayHello();
}

实施

public class SayHelloService : ISayHelloService
{
    public string SayHello()
    {           
        return "Hello! This is Hello Message From EBS Middleware Service App ";
    }
}

的Web.config

<configuration>

<appSettings>
  <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.2"/>
<httpRuntime targetFramework="4.5.2"/>
<httpModules>
  <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/>
</httpModules>
</system.web>
<system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior name="DefaultServiceBehavior">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="EndPointBehavior">
      <webHttp/>
    </behavior>
  </endpointBehaviors>
 </behaviors>

 <services>
  <service name ="HelloWorldService.SayHelloService" behaviorConfiguration="DefaultServiceBehavior">
    <endpoint address="" contract="HelloWorldService.ISayHelloService" binding="webHttpBinding" behaviorConfiguration="EndPointBehavior"></endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
  </service>
</services>

<protocolMapping>
    <add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>    
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>

                                               

0 个答案:

没有答案