Web service - definer tagnavn i output
Jeg har lavet en webservice der retunere et string array. Når jeg kalder denne service får jeg:<ArrayOfString>
<string>10 years</string>
<string>12 years</string>
<string>14 years</string>
</ArrayOfString>
Hvordan kan jeg næmmest definere tagnavnene (ArrayOfString og string)?
Kode til service:
[WebMethod(BufferResponse=true, CacheDuration=0, MessageName="getChoices",
Description="Retrives choices for a specific question - given a questionId")]
public string[] getChoices(int questionId, string language, string sessionId)
{
string[] choices = null;
choices = new string[3];
if(IsSessionValid(sessionId))
{
SqlParameter[] aParams = new SqlParameter[2];
aParams[0] = new SqlParameter("@intQuestionId", SqlDbType.Int);
aParams[0].Value = questionId;
aParams[1] = new SqlParameter("@strLanguage", SqlDbType.NVarChar);
aParams[1].Value = language;
SqlDataReader sdr = SqlHelper.ExecuteReader(ConfigurationSettings.AppSettings["ConnectionString"],
CommandType.StoredProcedure,
"GetChoices", aParams);
int count = 0;
while(sdr.Read())
{
choices[count] = sdr["strChoice"].ToString();
count++;
}
}
return choices;
}