webservice.asmx 是用xml作为底层传输数据的格式
碰到那种一定要求使用json格式的情况就比较麻烦
可以用aspx响应请求(效率不是很好,毕竟是页面类型)
string postString = string.Empty;
if (HttpContext.Current.Request.HttpMethod.ToUpper() == "POST")
{
using (Stream stream = HttpContext.Current.Request.InputStream)
{
stream.Seek(0, SeekOrigin.Begin);
Byte[] postBytes = new Byte[stream.Length];
stream.Read(postBytes, 0, (Int32)stream.Length);
postString = Encoding.UTF8.GetString(postBytes);
}
if (!string.IsNullOrEmpty(postString))
{
Response.Write(postString);
Response.End();
}
}
else
{
HttpContext.Current.Response.Clear();
Response.Write("error");
Response.End();
}