android - 为什么 Google Cloud Endpoints 会颠倒我的参数顺序?

标签 android google-cloud-endpoints

我有以下端点方法:

public class PlayerEndpoint {
  private static final String PLAYER_NAME = "player_name";
  private static final String PLAYER_UUID = "player_uuid";

  @ApiMethod(name = "register", httpMethod = ApiMethod.HttpMethod.POST, path="register")
  public Player register(@Named(PLAYER_UUID) String uuid,
                         @Named(PLAYER_NAME) String playerName) {
  log.info(String.format("Registering user uuid: %s name: %s", uuid, playerName));
  ...
  }
}

当我从我的 Android 客户端调用它时:

String uuid = "test_uuid";
String name = "test_name";
playerEndpoint.register(uuid, name).execute();

后端日志:

Registering user uuid: test_name name: test_uuid

这是怎么回事?

最佳答案

我想通了。显然,Endpoints 按字母顺序对您的方法进行排序。

Method parameters in the generated client library are in alphabetical order, regardless of the original order in the backend method. As a result, you should be careful when editing your methods, especially if there are several parameters of the same type. The compiler will not be able to catch parameter-ordering errors for you.

https://cloud.google.com/developers/articles/google-cloud-endpoints-for-android/

关于android - 为什么 Google Cloud Endpoints 会颠倒我的参数顺序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30157677/

相关文章:

Android 在一天中的特定时间设置重复闹钟

python - 部署时是否应包含 Cloud Endpoints Frameworks 库?

google-app-engine - 保护 Google Cloud Endpoints API

android - 在 Activity 中保存数组

google-cloud-platform - GCP 端点 "Try this API"授权 URL

java - JSON - 使用 Gson 反序列化客户端类

google-cloud-platform - 将谷歌端点中的路径参数传递给后端不起作用

安卓 Activity 堆栈

android - 使用复选框从 ListView 中获取选中的项目

android - 我如何在 android 的 surfaceview 上绘制字节数组?