我是新手。请在这方面帮助我。在 WCF 休息应用程序中,我想要以下响应
<parameterList>
<parameter>
<Question> Occupation </Question>
<Choice> Student/Others </Choice>
<Choice> Retired/housewife </Choice>
<Choice> Salaried/SelfEmployed </Choice>
<Choice> Doctor/CA/Socially Important Person </Choice>
</parameter>
</parameterList>
我想要 4 个具有不同内容的相同“选择”标签。我得到的只是最后一个“选择”标签。
IService.cs
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "/getQuestion")]
[return: MessageParameter(Name = "parameterList")]
List<parameter> getQuestion();
服务.svc.cs
public List<parameter> getQuestion()
{
List<parameter> lstParameter = new List<parameter>();
parameter param = new parameter();
param.Question = " Occupation ";
param.Choice = " Student/Others ";
param.Choice = " Retired/housewife ";
param.Choice = " Salaried/SelfEmployed ";
param.Choice = " Doctor/CA/Socially Important Person ";
lstParameter.Add(param);
return lstParameter;
}
参数.cs
public class parameter
{
public string Question
{
get{ } set{ }
}
public string Choice
{
get{ } set{ }
}
}