hi
I have a problem I am trying do call a method that return an externalizable object using the asynchone method of webservice call but the respond I receive is an error. In the following I present the code I use to do the work.
1- This is the code of the externalizable object I use
public class Message implements Externalizable {
private String byLogin;
private String text;
private long when;
static {
Util.register("Message",Message.class);
}
public int getVersion() {
return 1;
}
public String getByLogin() {
return byLogin;
}
public void setByLogin(String byLogin) {
this.byLogin = byLogin;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public long getWhen() {
return when;
}
public void setWhen(long when) {
this.when = when;
}
public void externalize(DataOutputStream out) throws IOException {
Util.writeUTF(byLogin, out);
Util.writeUTF(text, out);
out.writeLong(when);
}
public void internalize(int version, DataInputStream in) throws IOException {
byLogin = Util.readUTF(in);
text = Util.readUTF(in);
when = in.readLong();
}
public String getObjectId() {
return "Message";
}
}
2-This is the asychrone method call in my client side
Button bt5 = new Button("externalizable object display");
bt5.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
WebServiceProxy.pollAsync("moussa", new Callback<Externalizable>() {
public void onSucess(Externalizable value) {
Util.register("Message",Message.class);
Dialog.show("serveur message","respond is ok","OK",null);
}
public void onError(Object sender, Throwable err, int errorCode, String errorMessage) {
Dialog.show("serveur error","error","OK",null);
}
}
);
3-This is the code generated by the webservice wizard on my server side to call the methode poll
if(methodName.equals("poll")) {
Util.register("Message",Message.class); //This ligne is added by me
Object[] args = ProxyServerHelper.readMethodArguments(di, def_poll);
ProxyServerHelper.writeResponse(response, def_poll, WebServiceProxyServer.poll((String)args[0]));
return;
}
4- This is the code of how I am trying to display the externalizable object to the client on the server side base on the code generated by the webservicewizard
public static com.codename1.io.Externalizable poll(String Login) {
System.out.println(Login);
// your code goes here...
Externalizable message = new Message() ;
Message m = new Message();
m.setByLogin(Login);
m.setText(Login);
m.setWhen(System.currentTimeMillis());
Message ms = (Message)m ;
return ms;
}
please help. Thank