我期待這個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());
}
您是否真的嘗試過在tuturial中制定項目?我懷疑這個調用是一個代理調用,它需要一些代理而不是直接的方法調用。 –