强制忽略一些 url 参数

forcing to ignore some url parameters

我正在制作一个 iPhone 应用程序,我正在使用 .NET 网络服务。

假设下面是我的URL。

http://www.myweb.com/wser.asmx/listOfStudents?class=12

我在此处获取包含以下字段的学生列表。

Name
Roll Number
Class

现在客户要求制作阿拉伯语版本。所以我们将查询更新为以下内容。

http://www.myweb.com/wser.asmx/listOfStudents?class=12&appLang=ar
                                                      ^^^^^^^^^^^^

为了进行测试,我们在另一台服务器上更新了网络服务并进行了检查,一切正常。

现在,在应用商店上传应用时,我注意到如果我更新实际的网络服务,当前应用将无法运行,因为应用商店中的当前应用缺少 appLang 变量。

如果我不更新 webservice & apple go in testing,应用程序将崩溃,因为它会抛出缺少参数 appLang 的错误。

所以我在想的是,

我将上传新的网络服务,但 appLang 将默认为阿拉伯语。

就像我用更新的 web 服务执行 url http://www.myweb.com/wser.asmx/listOfStudents?class=12(appLang 添加到 web 服务中但不在 url 中),它不会抛出 parameter missing appLang 的错误?

有什么方法可以设置默认参数吗?

虽然在这种情况下使用 GET 不是很好(POST 可能更合适),但您可以这样做:

//by specifying a messageName, you can do overloading with webmethods
[WebMethod (MessageName = "listOfStudentsDefault")]  
[ScriptMethod(UseHttpGet=true)]
public string listOfStudents(int class, string appLang)
{
    // code here...
}

[WebMethod (MessageName = "listOfStudents")]  
[ScriptMethod(UseHttpGet=true)]
public string listOfStudents(int class)
{
    return listOfStudents(class, "ar");
}