[ScriptMethod(UseHttpGet = true)]
[WebMethod]
public string sampleTest()
{
string name = "";
name = System.Web.HttpContext.Current.Request.QueryString["name"];
StringBuilder sb = new StringBuilder();
sb.Append("<message>");
sb.Append("<categoryname =" + name + "/>");
sb.Append("</message>");
return sb.ToString();
}
Метод вызова:
StringBuilder sb = new StringBuilder();
byte[] buf = new byte[8192];
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost/mylytica/apibridge.asmx/sampleTest?name=Shankar");
HttpWebResponse response = (HttpWebResponse)
request.GetResponse();
Stream resStream = response.GetResponseStream();
string tempString = null;
int count = 0;
do
{
count = resStream.Read(buf, 0, buf.Length);
if (count != 0)
{
tempString = Encoding.ASCII.GetString(buf, 0, count);
sb.Append(tempString);
}
}
while (count > 0);
Literal1.Text = sb.ToString();
Литеральное значение содержит:
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/"><message loginstatus="OK" userid="1" /></string>
Фактический формат:
<message loginstatus="OK" userid="1" />
Что мне нужно сделать.