I created website to host web service when run it raise runtime error
The contract name 'ITry' could not be found in the list of contracts implemented by the service 'Try'.
My WCF service interface and class look like that
namespace test1
{
[ServiceContract]
public interface ITry
{
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "data/{username}/{password}")]
string Login(string username, string password);
}
}
Service implementation:
namespace test1
{
public class Try : ITry
{
public string Login(string username, string password)
{
using (var instance = new FacultySystemEntities1())
{
var user = instance.Users.Where(u => u.UserName == username && u.UserPassword == password).FirstOrDefault();
if (user != null)
return "true";
else
return "false";
}
}
}
}
and the web site , web.config is look like
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
<services>
<service name="test1.Try">
<endpoint address="http://localhost:8732/Try" binding="webHttpBinding" contract="ITry"/>
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Update the contract attribute from "ITry" to "test1.ITry" in the web.config.
<services>
<service name="test1.Try">
<endpoint address="http://localhost:8732/Try" binding="webHttpBinding" contract="test1.ITry"/>
</service>
</services>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.