我在这里查看这篇 MSDN 文章:http: //msdn.microsoft.com/en-us/library/bb924552.aspx
在文件后面的代码中,他们创建了一个名为 CostOfSandwiches 的函数,该函数接受一个名为数量的 int 参数。
当他们引用函数客户端时,他们传递 4 个参数。我想知道这些额外参数是在哪里定义的,它们的用途等等。
这是服务器端代码:
public class CostService
{
[OperationContract]
public double CostOfSandwiches(int quantity)
{
return 1.25 * quantity;
}
// Add more operations here and mark them with [OperationContract]
}
这是客户端调用:
function Button1_onclick() {
var service = new SandwichServices.CostService();
service.CostOfSandwiches(3, onSuccess, null, null);
}
function onSuccess(result){
alert(result);
}
是否有一些可以传递的可选参数的标准列表?记录此内容的链接?
编辑:在与同事询问后,他给我发了这个。任何人都知道这是在哪里产生的以及由什么产生的?
function Sys$Net$WebServiceProxy$_invoke(servicePath, methodName, useGet, params, onSuccess, onFailure, userContext) {
/// <summary locid="M:J#Sys.Net.WebServiceProxy._invoke" />
/// <param name="servicePath" type="String"></param>
/// <param name="methodName" type="String"></param>
/// <param name="useGet" type="Boolean"></param>
/// <param name="params"></param>
/// <param name="onSuccess" type="Function" mayBeNull="true" optional="true"></param>
/// <param name="onFailure" type="Function" mayBeNull="true" optional="true"></param>
/// <param name="userContext" mayBeNull="true" optional="true"></param>
/// <returns type="Sys.Net.WebRequest" mayBeNull="true"></returns>
var e = Function._validateParams(arguments, [
{name: "servicePath", type: String},
{name: "methodName", type: String},
{name: "useGet", type: Boolean},
{name: "params"},
{name: "onSuccess", type: Function, mayBeNull: true, optional: true},
{name: "onFailure", type: Function, mayBeNull: true, optional: true},
{name: "userContext", mayBeNull: true, optional: true}
]);
if (e) throw e;
onSuccess = onSuccess || this.get_defaultSucceededCallback();
onFailure = onFailure || this.get_defaultFailedCallback();
if (userContext === null || typeof userContext === 'undefined') userContext = this.get_defaultUserContext();
return Sys.Net.WebServiceProxy.invoke(servicePath, methodName, useGet, params, onSuccess, onFailure, userContext, this.get_timeout(), this.get_enableJsonp(), this.get_jsonpCallbackParameter());
}