Hi,
thanks a lot for the help. I'm despaired..
This code, work ok in J2ME. If I try get the String or Int like
return, work fine. But the error it occurs when I try readObject in
microHessian.
I can get the object, but I can't serialize again in my object (TO).
How can I resolve? I try (as you it said) implement MicroHessianOutput
in my web Service. The objective is in My Web Service, I search in
DataBase a List o objects, ans return this objects from my client
(J2ME - CDC).
new code WebService:
public void metodoSimples() throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
MicroHessianOutput out = new MicroHessianOutput(bos);
ProdutoTO prod = new ProdutoTO();
prod.setCodigo(1);
prod.setDescricao("prod palhaco");
out.writeObject(prod);
}
Client J2ME code:
String url =
"http://localhost:8084/br.com.rosaFlores.WebService/test";
HttpConnection c = (HttpConnection) Connector.open(url);
c.setRequestMethod(HttpConnection.POST);
OutputStream os = c.openOutputStream();
MicroHessianOutput out = new MicroHessianOutput(os);
out.startCall("metodoSimples");
out.completeCall();
os.flush();
InputStream is = c.openInputStream();
MicroHessianInput in = new MicroHessianInput(is);
in.startReply();
Object obj = in.readObject(null);
--
PS: this code don't work. Now, I can't read the object...
But in MicroHessian, I dont have the startMessage() or close(), as my last code.
Did you have any idea? How van I make this simple code work? Ist very
simple. I need transfer a List of objects (Car, Product, Client, etc..
) as POJO in my client aplication (J2ME - CDC).
The sample that I found in hessian site, just work for J2SE client.
I wiil be returna array of byte (byte[]) ? Or I will be return void,
and write object (as sample) and readObject in my client?
thanks a lot!
Fábio
Server code:
public byte[] returnTO() throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
Hessian2Output out = new Hessian2Output(bos);
out.startMessage();
ProdutoTO prod = new ProdutoTO();
prod.setCodigo(1);
prod.setDescricao("prod palhaco");
out.completeMessage();
out.close();
return bos.toByteArray();
}
Client (J2me - CDC):
String url =
"http://localhost:8084/br.com.rosaFlores.WebService/test";
HttpConnection c = (HttpConnection) Connector.open(url);
c.setRequestMethod(HttpConnection.POST);
OutputStream os = c.openOutputStream();
MicroHessianOutput out = new MicroHessianOutput(os);
out.startCall("returnTO");
out.completeCall();
os.flush();
InputStream is = c.openInputStream();
MicroHessianInput in = new MicroHessianInput(is);
in.startReply();
//int total = in.readInt();
//String ok = in.readString();
Object obj = in.readObject(null);
2007/10/1, Scott Ferguson <[EMAIL PROTECTED]>:
>
> On Oct 1, 2007, at 9:39 AM, Fábio Pinheiro wrote:
>
> > Hi,
> > I can't resolve this problem.
> >
> > In my client application (J2ME - CDC), I can get the return when is a
> > String or a int. But, i get the a object (TO sample, as Product). The
> > return is a byte[] (array).
> >
> > How can I serialize again in my object?
>
> You need to use the MicroHessian on both sides of the connection.
>
> Also, if you're using "startReply" on the client, you need to use
> "startReply" on the server. The two sides need to match.
>
> -- Scott
>
> >
> > Server code:
> > public byte[] returnTO() throws Exception {
> > ByteArrayOutputStream bos = new ByteArrayOutputStream();
> > Hessian2Output out = new Hessian2Output(bos);
> >
> > out.startMessage();
> >
> > ProdutoTO prod = new ProdutoTO();
> > prod.setCodigo(1);
> > prod.setDescricao("prod palhaco");
> >
> > out.completeMessage();
> >
> > out.close();
> >
> > return bos.toByteArray();
> > }
> >
> > Client (J2me - CDC):
> > String url =
> > "http://localhost:8084/br.com.rosaFlores.WebService/test";
> > HttpConnection c = (HttpConnection) Connector.open
> > (url);
> >
> > c.setRequestMethod(HttpConnection.POST);
> >
> > OutputStream os = c.openOutputStream();
> > MicroHessianOutput out = new MicroHessianOutput(os);
> >
> > out.startCall("returnTO");
> >
> > out.completeCall();
> >
> > os.flush();
> >
> > InputStream is = c.openInputStream();
> > MicroHessianInput in = new MicroHessianInput(is);
> >
> > in.startReply();
> >
> >
> > //int total = in.readInt();
> > //String ok = in.readString();
> >
> > Object obj = in.readObject(null);
> >
> > ------------
> >
> > If I ask the instanceof the obj, is a array byte (byte[]).
> > i can't make a cast for my object, teturn error.
> >
> > How can I cast (or serialize) this object in my TO?
> >
> > Please, this is the 3º post about this problem.
> >
> > If anybody can use hessian (return a List of TO [POJO]), please...
> >
> > thanks,
> > Fabio
> >
> >
> > _______________________________________________
> > hessian-interest mailing list
> > [email protected]
> > http://maillist.caucho.com/mailman/listinfo/hessian-interest
>
>
_______________________________________________
hessian-interest mailing list
[email protected]
http://maillist.caucho.com/mailman/listinfo/hessian-interest