[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public LoginResponse SignUp(string email, string password)
{
LoginResponse s = new LoginResponse();
//s.Code = "123434";
//s.Message = "Signup succeed";
//s.UserId = "";
return s;
}
[WebMethod]
public SendCodeResponse SendCode(string userId, string barCode)
{
SendCodeResponse scr = new SendCodeResponse();
scr.code = "";
return scr;
}
[Serializable]
public class LoginResponse
{
string code;
string message;
string userId;
[XmlElement(Type = typeof(string), ElementName = "Code")]
public string Code
{
get { return code; }
set { code = value; }
}
[XmlElement(Type = typeof(string), ElementName = "Message")]
public string Message
{
get { return message; }
set { message = value; }
}
[XmlElement(Type = typeof(string), ElementName = "UserId")]
public string UserId
{
get { return userId; }
set { userId = value; }
}
}
[Serializable]
public class SendCodeResponse
{
string code;
[XmlElement(Type = typeof(string), ElementName = "Code")]
public string Code
{
get { return code; }
set { code = value; }
}
}
When I run this webservice it gives me Server Error in '/' Application.
The XML element 'SendCodeResponse' from namespace 'http://tempuri.org/' references a method and a type. Change the method's message name using WebMethodAttribute or change the type's root element using the XmlRootAttribute.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The XML element 'SendCodeResponse' from namespace 'http://tempuri.org/' references a method and a type. Change the method's message name using WebMethodAttribute or change the type's root element using the XmlRootAttribute.
Please help me.