облачно-конечные точки.
Я следую Udacity tutorial.ia бит путают с потоком запроса и ответа, ниже мое понимание
Конечная точка должна быть аннотирована @Api
, а метод конечной точки аннотируется с помощью @ApiMethod
, и эти методы не должны возвращать примитивные типы данных. это один оконечных методпонимание google-cloud-endpoints?
@ApiMethod(name = "saveProfile", path = "profile", httpMethod = HttpMethod.POST)
public Profile saveProfile(ProfileForm profileForm) throws UnauthorizedException {
String userId = null;
String mainEmail = null;
String displayName = "Your name will go here";
TeeShirtSize teeShirtSize = TeeShirtSize.NOT_SPECIFIED;
if(profileForm.getTeeShirtSize() != null)
teeShirtSize = profileForm.getTeeShirtSize();
displayName = profileForm.getDisplayName();
Profile profile = new Profile(userId, displayName, mainEmail, teeShirtSize);
return profile;
}
внизу мои ProfileForm и профильные классы
public class ProfileForm {
private String displayName;
private TeeShirtSize teeShirtSize;
private ProfileForm() {}
public ProfileForm(String displayName, TeeShirtSize teeShirtSize) {
this.displayName = displayName;
this.teeShirtSize = teeShirtSize;
}
public String getDisplayName() {
return displayName;
}
public TeeShirtSize getTeeShirtSize() {
return teeShirtSize;
}
public static enum TeeShirtSize {
NOT_SPECIFIED,
XS,
S,
M,
L,
XL,
XXL,
XXXL
}
}
public class Profile {
String displayName;
String mainEmail;
TeeShirtSize teeShirtSize;
String userId;
public Profile (String userId, String displayName, String mainEmail, TeeShirtSize teeShirtSize) {
this.userId = userId;
this.displayName = displayName;
this.mainEmail = mainEmail;
this.teeShirtSize = teeShirtSize;
}
public String getDisplayName() {
return displayName;
}
public String getMainEmail() {
return mainEmail;
}
public TeeShirtSize getTeeShirtSize() {
return teeShirtSize;
}
public String getUserId() {
return userId;
}
private Profile() {}
}
Здесь ProfileForm
является параметром запроса и Profile
является response.i развертывается в locahost и с помощью ниже URL я испытал
http://localhost:8080/_ah/api/explorer в теле запроса я добавил два параметра, как DISPLAYNAME, teeShirtSize Так может любой, пожалуйста, объясните почему я получаю ответ как 404? ниже изображен снимок экрана
И, насколько мне известно, мне не нужно загружать appengine client.js, потому что я не тестирую на веб-странице. Я тестирую в api-explorer. Пожалуйста, объясните, как генерируется ответ при вызове google-cloud-endpoint?
Thanks
Можете ли вы разместить свой код для ProfileForm? – Eliot
@Eliot благодарит за ваш ответ, и теперь я добавил классы ProfileForm и Profile. – prasad
вы получаете какие-либо журналы на вашем сервере GAE, показывая, что вы на самом деле попали в конечную точку? – jirungaray