Hi,
I have a problem in consuming Hessian Web Service(3.1.2) in my aplication
CDC - for Pocket PC.
I get the sample in the hessian site, and for a method that return a simple
String, all work.
But when I do a method that return byte[] (in thrue, a list of object TO),
the same code that work in Java SE not work in my aplication mobile (J2ME -
CDC).
The code in server:
public byte[] downloadProducts() throws Exception {
// return list object (TO) from hibernate
List ret = ProdutoBO.getInstance().findAllProduto();
if (ret.size() > 0) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
Hessian2Output out = new Hessian2Output(bos);
out.startMessage();
//out.writeInt(ret.size());
for(Iterator iter = ret.iterator(); iter.hasNext();) {
Produto prod = (Produto)iter.next();
// Convert to another object (ProdutoMer) because I have
problems with hessian + hibernate serialization (lazy).
ProdutoMer produtoMer = new ProdutoMer();
produtoMer.setCodigo(prod.getCodigo());
produtoMer.setDescricao(prod.getDescricao());
produtoMer.setId(prod.getId());
produtoMer.setImportado(prod.getImportado());
produtoMer.setPrecoCompra(prod.getPrecoCompra());
produtoMer.setPrecoVenda(prod.getPrecoVenda());
produtoMer.setSubGrupoProdutoID(prod.getSubGrupoProduto
().getId());
produtoMer.setTipoOrigem(prod.getTipoOrigem());
// Put the object in the list return of hessian.
out.writeObject(produtoMer);
}
out.writeString(String.valueOf(ret.size()));
out.completeMessage();
out.close();
return bos.toByteArray();
}
else {
return null;
}
}
---------------------------------------
Now, the code that dont work in my mobile aplication (J2ME - CDC):
try { // Call Web Service Operation
String url = "
http://192.168.0.101:8080/br.com.xFlower.WebService/test";
HttpConnection c = (HttpConnection) Connector.open
(url);
c.setRequestMethod(HttpConnection.POST);
OutputStream os = c.openOutputStream();
MicroHessianOutput out = new MicroHessianOutput(os);
out.startCall("downloadProducts");
out.completeCall();
os.flush();
InputStream is = c.openInputStream();
MicroHessianInput in = new MicroHessianInput(is);
in.startReply();
int total = in.readInt();
ArrayList listTO = new ArrayList(total);
for(int i = 0; i < total; i++) {
listTO.add(in.readObject(ProdutoMer.class));
}
in.completeReply();
} catch (Exception ex) {
thinlet.setString(senha, "text", ex.getLocalizedMessage());
}
---------------
Please, any idea is good. I can`t use hessian and no other Web Service in my
aplication J2ME CDC.
I`m with this problem one week.
thanks a lot!
Fabio Pinheiro
Brasil
_______________________________________________
hessian-interest mailing list
[email protected]
http://maillist.caucho.com/mailman/listinfo/hessian-interest