1
私はRESTletフレームワークを使用しています。Restletフレームワーク。シリアライゼーション。どのようにオブジェクトを送受信するのか理解していない
サーバーがクライアントから送信されたオブジェクトをどのように受け取ることができるのか分かりません。例えば。 私はクライアント側でそのようなインタフェースを持っている:
public interface AuthorizationResource {
@Post
public void login(Authentication auth);
}
は、それから私は、サーバーへの認証クラスのオブジェクトを送信:
Authentication auth = new Authentication ("login", "password");
resource.login(auth);
認証クラス(両方のクラスは、サーバーとクライアントでも利用できます):
public class Authentication implements Serializable{
private static final long serialVersionUID = 1L;
public String login;
public String password;
public Authentication() {}
public Authentication(String login, String password) {
super();
this.login = login;
this.password = password;
}
public String getLogin() {
return login;
}
public String getPassword() {
return password;
}
public void setLogin(String login) {
this.login = login;
}
public void setPassword(String password) {
this.password = password;
}
}
はその後、サーバー側では、私は、認証クラスのオブジェクトを取得したい:
public class AuthenticationServerResource extends ServerResource {
Authentication auth = new Authentication("defaultLogin", "defaultPassword");
@Post
public void login (Authentication auth) {
this.auth = auth;
System.out.println(auth.getLogin());
}
}
ただし、何も起こりません。コンソールは何も出力しません。
私の質問は、オブジェクトをシリアル化する最良の方法ですか?私の道は正しいのですか?
私はあなたにそれらを渡す方法を見るためにrestletの 'Representation'を調べることをお勧めします。ヒント: 'ClientResource'または' clientDispatcher'を介してサーバーリソースを呼び出し、 'login'メソッドを直接呼び出さないでください... – PhD