Hi, I`m using Hessian, with TomCat, and if my client in J2SE, all work. But, when I need
implement my client in a Pocket PC (I use Creme 4.12 - (J2ME CDC/Personal Profile 1.0 specification)). In hessian website, i found a sample [Hessian Client for a cell-phone] in: http://www.caucho.com/resin-3.0/protocols/hessian.xtp A simple method that return a string, work ok in my Pocket PC, with MicroHessian. But, When I need transfer a list de object (TO), not work. Server code: public byte[] downloadProdutos() throws Exception { 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(); // Converte to ProdutoMer, because problems with hibernate serialization with lazy-load list). 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()); out.writeObject(produtoMer); } out.completeMessage(); out.close(); return bos.toByteArray(); } else { return null; } } --------------------------------------------------------------------------- Client (J2SE/JSF( - this sample work fine) public String btnDownload_action() { try { HessianProxyFactory factory = new HessianProxyFactory(); WSRosaFlores ws = (WSRosaFlores)factory.create( WSRosaFlores.class, "http://192.168.0.101:8080/br.com.rosaFlores.WebService/test"); byte[] dataRet = ws.downloadProdutos(); ByteArrayInputStream bin = new ByteArrayInputStream(dataRet); Hessian2Input in = new Hessian2Input(bin); in.startMessage(); ArrayList list = new ArrayList(); int length = in.readInt(); for(int i = 0; i < length; i++) { list.add(in.readObject()); } in.completeMessage(); in.close(); bin.close(); // Percorre os itens encontrados for(Iterator iter = list.iterator(); iter.hasNext();) { ProdutoMer prod = (ProdutoMer)iter.next(); System.out.println(prod.getId()); System.out.println(prod.getCodigo()); System.out.println(prod.getDescricao()); } } catch(Exception ex) { System.out.println(ex.getMessage()); } return null; } Obs: In this sample, my web method return a byte[], but in output I write a number of objects tha I want retturn. ----------------------------------------------------------------- Mobile code (PC - Creme JVM): public void showPage(String pageName, Thinlet thinlet) { Object senha = thinlet.find("txtSenha"); try { // Call Web Service Operation String url = " http://192.168.0.101:8080/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("downloadProdutos"); out.completeCall(); os.flush(); InputStream is = c.openInputStream(); MicroHessianInput in = new MicroHessianInput(is); in.startReply(); byte[] result = in.readBytes(); 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()); } } In this code, the error is in line: int total = in.readInt(); The error is: expected bytes at f My objective is create a Web Service, that find a lot of informations, how a list of Products, ans return this products for my PocketPc, and write this informations in a database local (HSQLDB). thanks! Fábio Pinheiro Brasil - SP
_______________________________________________ hessian-interest mailing list [email protected] http://maillist.caucho.com/mailman/listinfo/hessian-interest
