<%@ WebService Language=
"C#"
Class=
"TestWebService"
%>
using
System;
using
System.Web;
using
System.Web.Services;
using
System.Web.Services.Protocols;
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public
class
TestWebService : System.Web.Services.WebService {
//原先通过return方式返回的是XML格式的结果
[WebMethod]
public
string
HelloWorld_Old(
string
firstName,
string
lastName)
{
//return string.Format("Hello {0} {1}", firstName, lastName);
return
"{'success':true,'firstName':'"
+ firstName +
"','lastName':'"
+ lastName +
"'}"
;
}
//通过Response 输出string类型
[WebMethod]
public
void
HelloWorld(
string
firstName,
string
lastName)
{
//return string.Format("Hello {0} {1}", firstName, lastName);
string
rtnStr=
"{'success':true,'firstName':'"
+ firstName +
"','lastName':'"
+ lastName +
"'}"
;
this
.Context.Response.Write(rtnStr);
}
}