I´m developing a class to send two files and two parameters to the server. The code I use is the following. The problem I get this time is that it only sends the files and not the parameters. If I commet the line that says pM.setRequestEntity(new MultipartRequestEntity(partes, pM.getParams())) then it sends the parameters without problems.

           pM = new PostMethod(url.toString());
byte [] oA = "abc".getBytes();
           byte [] oP = "def".getBytes();
pM.addParameter("fI", "12/31/2004");
           pM.addParameter("fF", "12/31/2005");
ByteArrayPartSource horA = new ByteArrayPartSource("horA.xml", oA); ByteArrayPartSource horP = new ByteArrayPartSource("horP.xml", oP); FilePart p1 = new FilePart("hA", horA);
           FilePart p2 = new FilePart("hP", horP);
           Part[] partes = {p1, p2};
pM.setRequestEntity(new MultipartRequestEntity(partes, pM.getParams()));
           NameValuePair [] parametros = new NameValuePair[2];
           parametros[0] = new NameValuePair("fechaInicio", "12/31/2004");
           parametros[1] = new NameValuePair("fechaFin", "12/31/2005");
           pM.setRequestBody(parametros);
pM.setRequestEntity(new MultipartRequestEntity(partes, pM.getParams()));
           HttpClient cliente = new HttpClient();
cliente.getHttpConnectionManager().getParams().setConnectionTimeout(30000);
           int estado = cliente.executeMethod(pM);
           if (estado == HttpStatus.SC_OK) {
               System.out.println(
"Upload finished, response=" + pM.getResponseBodyAsString()
               );
           } else {
               System.out.println(
"Upload failed, response=" + HttpStatus.getStatusText(estado)
               );
           }
           pM.releaseConnection();

Do somebody can help me?

Thanks in advance

Rosa

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to