Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/08/2014, 09:03
jhonne25_64
 
Fecha de Ingreso: mayo-2013
Ubicación: Armenia, Quindio, Colombia,
Mensajes: 95
Antigüedad: 10 años, 11 meses
Puntos: 3
mensaje con HttpClient enviando mensajes multipartes

Hola a todos,
Mi pregunta es como componer un mensaje Multiparte con la API HttpClient. Lo que quiero exactamente es que la primera parte sea un xml (Content-Type: application/xml), y la segunda un texto (Content-Type: text/html). Cuando hago la solicitud el servidor responde indicando que el tipo debe ser application/xml. Así se compongo el mensaje multiparte con apache httpclient
Código:
StringPart xmlPart= new StringPart("xml", xml);
			xmlPart.setContentType("application/xml");
			StringPart textPart= new StringPart("text", "Hola mundo");
			textPart.setTransferEncoding("binary");
			textPart.setContentType("text/html");
			method.setRequestEntity(new MultipartRequestEntity(new Part[]{xmlPart,textPart}, method.getParams()));
El mensaje que debo componer es:

Código:
 --PMasdfglkjhqwert
Content-Type: application/xml
<?xml version="1.0"?>
<!DOCTYPE pap PUBLIC "-//WAPFORUM//DTD PAP 2.1//EN" 
"http://www.openmobilealliance.org/tech/DTD/pap_2.1.dtd">
<pap>
  <push-message push-id="999999999"
                source-reference="AAAAAAAAAAAA"
                deliver-before-timestamp="2008-09-31T13:30:00Z"
                ppg-notify-requested-to="notify_url_path">
    <address address-value="PIN00001"/>
    <address address-value="PIN00002"/>
    <address address-value="PIN00003"/>
    <quality-of-service  delivery-method="confirmed"/>
  </push-message>
</pap>
--PMasdfglkjhqwert
Content-Encoding: binary
Content-Type: text/html

Text or binary content to be pushed to BlackBerry device goes here.

 --PMasdfglkjhqwert--
y lo que me responde el servidor es:
Código:
 
<!DOCTYPE pap PUBLIC "-//WAPFORUM//DTD PAP 2.1//EN" "http://www.openmobilealliance.org/tech/DTD/pap_2.1.dtd"><pap><badmessage-response code="2000" desc="Received content type is not &apos;application/xml&apos;" bad-message-fragment="Received content type is not &apos;application/xml&apos;"/></pap>
Por fa, no encuentro un ejemplo de como enviar un xml en contenido multiparte.
Muchas gracias,
Saludos,