你是否觉得.Net Web Service 中asmx文件是多余的?---客户端调用
<object id="person" type="Spring.Web.Services.WebServiceProxyFactory,Spring.Services">
<!--地址-->
<property name="ServiceUri" value="http://localhost:53825/PersonService.asmx"></property>
<!--服务接口-->
<property name="ServiceInterface" value="SpringWebServiceIoCContract.IPerson, SpringWebServiceIoCContract"/>
</object>
<object id ="personObj" type="SpringWebServiceIoCContract.Person,SpringWebServiceIoCContract"></object></objects>
{
var person0 = context.GetObject("person") as IPerson;
if (null!=person0)
{
Console.WriteLine(person0.Add(1, 2));
}
}
type: "POST",
url: "WebService1.asmx/GetPerson",
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (json) { $(json.d).each(function () { alert(this.Name + "-" + this.Age ) }) },
error: function (error) {
alert("调用出错" + error.responseText);
}
});
<add verb="*" path="*.asmx" type="Spring.Web.Services.WebServiceHandlerFactory, Spring.Web"/>
</httpHandlers>
<httpModules>
<add name="SpringModule" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
</httpModules>
<add verb="*" path="*.asmx" type="Spring.Web.Script.Services.ScriptHandlerFactory, Spring.Web.Extensions"/>
</httpHandlers>
<httpModules>
<add name="SpringModule" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
</httpModules>
type: "POST",
url: "PersonService.asmx/GetPerson",
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (json) { $(json.d).each(function () { alert(this.Name + "-" + this.Age) }) },
error: function (error) {
alert("调用出错" + error.responseText);
}
});
{
Person person = new Person { Age = 25, Name = "zhangsan" };
return JsonConvert.SerializeObject(person);
}
type: "POST",
url: "PersonService.asmx/GetPerson",
data: { name: 'a' },
dataType: "JSON",
success: function (json) {
alert(new Function("return " + json.replace(/<[^>]+>|[\r\n]/g, ""))().Name)
},
error: function (error) {
alert("错误:" + error.responseText);
}
});
<add verb="*" path="*.asmx" type="Spring.Web.Script.Services.ScriptHandlerFactory, Spring.Web.Extensions"/>可以通过
function GetDataOnSucceeded()
{
alert("姓名:" + result.Name + "\n" + "年龄:" + result.Age);
}