我是WCF的新手并开始学习。我想为Android应用程序托管一个WCF服务,但我不知道如何调用一个方法以及什么是uritemplate。
IService是:
public interface IService1
{
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "UserReg", ResponseFormat = WebMessageFormat.Json)]
public string UserReg(string user_id, string first_name, string last_name, string email, string password);
}
,服务是:
public class Service1 : IService1
{
P_M_SEntities objEntities = new P_M_SEntities();
public string UserReg(string user_id, string first_name, string last_name, string email, string password)
{
User_Registration tblObj = new User_Registration();
tblObj.user_id = Convert.ToInt32(user_id);
tblObj.first_name = first_name;
tblObj.last_name = last_name;
tblObj.email = email;
tblObj.password = EncryptPwd(password);
objEntities.User_Registration.Add(tblObj);
objEntities.SaveChanges();
string objstring = tblObj.user_id.ToString();
return string.Format(objstring);
}
}
我不熟悉WCF,所以我非常感谢你的帮助。