当我通过在地址栏中输入查询字符串来测试我的WCF服务方法时,它只显示"未找到端点。"。请帮助我,我错了?但是添加两个数字的简单测试方法正常运行。我在localhost上运行它.Below是我的web.config
<connectionStrings>
<add name="ES_SecurityContext" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=dev_Scheduler;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.1" />
<httpRuntime targetFramework="4.5.1" executionTimeout="1599999" />
<customErrors mode="Off"/>
<membership defaultProvider="simple">
<providers>
<add name="simple" type="WebMatrix.WebData.SimpleMembershipProvider, WebMatrix.WebData"/>
</providers>
</membership>
</system.web>
<system.serviceModel>
<services>
<!--<service name="Cygnus.Dev.JobDispatcherWCFService.JobDispatcherWcf">
<endpoint address="" behaviorConfiguration="restfulBehavior" binding="webHttpBinding" bindingConfiguration="web" contract="Cygnus.Dev.JobDispatcherWCFService.IJobDispatcherWcf"></endpoint>
</service>-->
<service name="SchedulerWcf.Scheduler" behaviorConfiguration="ServiceBehavior">
<!--<host>
<baseAddresses>
<add baseAddress=""/>
</baseAddresses>
</host>-->
<endpoint binding="webHttpBinding" contract="SchedulerWcf.IScheduler" behaviorConfiguration="webHttp"/>
<endpoint address="mex" binding="mexHttpBinding" contract="SchedulerWcf.IScheduler" />
</service>
</services>
<behaviors>
<!--<endpointBehaviors>
<behavior name="restfulBehavior">
<webHttp helpEnabled="true"/>
</behavior>
</endpointBehaviors>-->
<serviceBehaviors>
<behavior name="ServiceBehavior" >
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webHttp">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" 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>
下面是WCF服务的代码
public class Scheduler : IScheduler
{
#region [Constructors]
public Scheduler()
{
if (!WebSecurity.Initialized)
WebSecurity.InitializeDatabaseConnection("ES_SecurityContext", "UserProfile", "UserId", "UserName", autoCreateTables: true);
}
#endregion
#region [Ping Test Methods]
public string GetSum(int x, int y)
{
return new JavaScriptSerializer().Serialize(new { sum = x + y, message = "This is sum" });
}
#endregion
#region [Methods]
public CompositeType GetDataUsingDataContract(CompositeType composite)
{
if (composite == null)
{
throw new ArgumentNullException("composite");
}
if (composite.BoolValue)
{
composite.StringValue += "Suffix";
}
return composite;
}