webMethod で C# webservice を使用しています。
[WebMethod]
public SignUpResponse SignUp(string email, string password)
{
SignUpResponse sr = new SignUpResponse();
if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
{
sr.ErrorCode = (int)ErrorCodes.RequestParametersUnavailable;
return sr;
}
try
{
UserDAO uda = new UserDAO();
if (uda.isEmailExist(email))
{
sr.ErrorCode = (int)ErrorCodes.UserAlreadyExist;
return sr;
}
UserData udata = uda.SignUp(email, password, (int)UserType.MobileUser);
sr.ErrorCode = (int)ErrorCodes.Successfull;
sr.Code = udata.CODE;
sr.Message = "SignUp Successfull";
sr.UserId = udata.USER_ID;
return sr;
}
catch
{
sr.ErrorCode = (int)ErrorCodes.UnexpectedError;
return sr;
}
}
[Serializable]
[XmlRoot("SignUpResponseL")]
public class SignUpResponse
{
string code;
string message;
int userId;
int errorCode;
[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(int), ElementName = "UserId")]
public int UserId
{
get { return userId; }
set { userId = value; }
}
[XmlElement(Type = typeof(int), ElementName = "ErrorCode")]
public int ErrorCode
{
get { return errorCode; }
set { errorCode = value; }
}
}
これを呼び出すと、次のように応答が返されます。
<SignUpResponseL xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
<Code>29054</Code>
<Message>SignUp Successfull</Message>
<UserId>5</UserId>
<ErrorCode>1</ErrorCode>
</SignUpResponseL>
しかし、私はそれを作りたい:
<SignUpResponseL>
<Code>29054</Code>
<Message>SignUp Successfull</Message>
<UserId>5</UserId>
<ErrorCode>1</ErrorCode>
</SignUpResponseL>
方法を教えてください。前もって感謝します