我在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>
请告诉我怎么做。 提前致谢
答案 0 :(得分:0)
XmlNamespaceManager
可用于删除命名空间。可以删除命名空间的删除方法
http://msdn.microsoft.com/en-us/library/system.xml.xmlnamespacemanager.removenamespace.aspx