[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; }
}
}
このWebサービスを実行すると、「/」アプリケーションでサーバーエラーが発生します。
名前空間'http://tempuri.org/'のXML要素'SendCodeResponse'は、メソッドとタイプを参照します。WebMethodAttributeを使用してメソッドのメッセージ名を変更するか、XmlRootAttributeを使用してタイプのルート要素を変更します。
説明:現在のWebリクエストの実行中に未処理の例外が発生しました。エラーとエラーがコードのどこで発生したかについての詳細は、スタックトレースを確認してください。
例外の詳細:System.InvalidOperationException:名前空間'http://tempuri.org/'のXML要素'SendCodeResponse'は、メソッドとタイプを参照します。WebMethodAttributeを使用してメソッドのメッセージ名を変更するか、XmlRootAttributeを使用してタイプのルート要素を変更します。
私を助けてください。