我在IIS中托管了一个WCF服务。我想像这样调用一个名为“hello”的方法:
本地主机:端口/ Service1.svc /你好
我的Service1.svc文件:
namespace WcfService2
{
public class Service1 : IService1
{
public String hello()
{
return "Hello!";
}
}
}
我的服务合同文件:
namespace WcfService2
{
[ServiceContract]
public interface IService1
{
[OperationContract]
[WebGet]
String hello();
}
}
我的Web.config文件:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="false" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<services>
<service behaviorConfiguration="Default" name="WcfService2.Service1">
<endpoint address="Get" behaviorConfiguration="behavior" binding="webHttpBinding" contract="WcfService2.IService1" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="behavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name ="Default">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
但是当我查找给定的URL时,我得到一个空白页面。我该怎么做呢?