Hi,
I have a problem with attachments, I develop a client to call a WS that send
email with files as an attachments, all work fine, but when a receive the mail
the files are corrupted nor have the size of original
I'm using CFX 2.2.7 and spring 3.0.1-MILESTONE
How can I verify the size before it is send to WS ?
Can I see more in depth log messages, how do I configure that?
Send my client code for further reference:
public void procesarPeticionCorreo( String[] args )
{
Mensaje mensaje = new Mensaje();
File archivoListas = null;
File archivoEmisnet = null;
File archivoAdjunto = null;
archivoListas = new File(args[0]);
archivoEmisnet = new File(args[1]);
archivoAdjunto = new File(args[2]);
int contadorArchivos=0;
DataSource source1 = null;
DataSource source2 = null;
Archivo archivo1 = new Archivo();
Archivo archivo2 = new Archivo();
String contenido="";
logger.debug("archivoListas: " + archivoListas.getAbsolutePath());
logger.debug("archivoEmisnet: " + archivoEmisnet.getAbsolutePath());
logger.debug("archivoAdjunto: " + archivoAdjunto.getAbsolutePath());
logger.debug("entro a procesaArchivoListasCorreo" );
List<String[]> listaCorreo=
archivoUtils.procesaArchivoListasCorreo(archivoListas);
logger.debug("salio de procesaArchivoListasCorreo" );
InputStream inputStream1 = null;
InputStream inputStream2 = null;
if (archivoEmisnet.exists() ){
if (archivoEmisnet.getName().endsWith("bmv")){
contenido= archivoUtils.procesaArchivoTexto(archivoEmisnet);
}
try {
inputStream1 = new
FileInputStream(archivoEmisnet);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
source1 = new
ByteArrayDataSource(inputStream1,
"application/octet-stream");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (inputStream1 != null) {
try {
inputStream1.close();
} catch (IOException e) {
// TODO Auto-generated
catch block
e.printStackTrace();
}
}
}
logger.debug("tipo de contenido"+ source1.getContentType());
archivo1.setNombreArchivo(archivoEmisnet.getName());
archivo1.setData(new DataHandler(source1));
contadorArchivos++;
}
if (archivoAdjunto.exists()){
try {
inputStream2 = new
FileInputStream(archivoAdjunto);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
source2 = new
ByteArrayDataSource(inputStream2,
"application/octet-stream");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (inputStream2 != null) {
try {
inputStream2.close();
} catch (IOException e) {
// TODO Auto-generated
catch block
e.printStackTrace();
}
}
}
archivo2.setNombreArchivo(archivoAdjunto.getName());
archivo2.setData(new DataHandler(source2));
contadorArchivos++;
}
logger.info("contador de archivos "+contadorArchivos);
Archivo[] archivos = new Archivo[contadorArchivos];
// si no esta especificado este valor crea los adjuntos
if (args[6]!=null && args[6].toLowerCase().equals("si")){
int i=0;
if (archivoEmisnet.exists()){
archivos[i]=archivo1;
}else if (archivoAdjunto.exists()){
archivos[i]=archivo2;
}
i++;
if (i<contadorArchivos)archivos[i]=archivo2;
mensaje.setArchivosAdjuntos(archivos);
}
// agrega pie de pagina
StringBuffer sb = new StringBuffer();
sb.append(contenido);
sb.append("\n");
sb.append("\n");
String PiePagina = propGenPub.getProperty("piePagina");
sb.append(PiePagina);
contenido= sb.toString();
mensaje.setContenido(contenido);
logger.debug("contenido "+contenido);
mensaje.setAsunto(args[3]);
mensaje.setDireccionRemitente(propGenPub.getProperty("direccionRemitente"));
mensaje.setNombreRemitente(propGenPub.getProperty("nombreRemitente"));
if (args[4]!=null && args[4].toLowerCase().equals("html")){
mensaje.setTipoContenido("HTML");
}else
{
mensaje.setTipoContenido(args[4]);
}
if (args[5]!=null){
mensaje.setCodificacion(args[5].toUpperCase());
}else{
mensaje.setCodificacion(propGenPub.getProperty("codificacion"));
}
mensaje.setDirecionRespuestas(propGenPub.getProperty("direccionRespuesta"));
mensaje.setNombreRespuestas(propGenPub.getProperty("nombreRespuestas"));
for (String[] strings : listaCorreo) {
mensaje.setDestinatarios(strings);
try {
int respuesta = servicios.enviaCorreo(mensaje);
logger.info("la respuesta es "+respuesta);
} catch (PublicadorException e) {
logger.error("Error reportado: "+e.getMessage());
e.printStackTrace();
}
}
}
This my xml configuration file:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:soap="http://cxf.apache.org/bindings/soap"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/bindings/soap
http://cxf.apache.org/schemas/configuration/soap.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
<bean id="properties"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location"
value="classpath:publicadorCliente.properties" />
</bean>
<bean id="cliente"
class="com.bursatec.publicador.cliente.correo.Cliente">
<property name="archivoUtils" ref="utils"></property>
<property name="servicios" ref="servicioWeb"></property>
<property name="propGenPub">
<props>
<prop key="direccionRemitente">
${publicador.prop.direccionRemitente}
</prop>
<prop key="piePagina">
${publicador.prop.piePagina}
</prop>
<prop key="nombreRemitente">
${publicador.prop.nombreRemitente}
</prop>
<prop key="codificacion">
${publicador.prop.codificacion}
</prop>
<prop key="direccionRespuesta">
${publicador.prop.direccionRespuesta}
</prop>
<prop key="nombreRespuestas">
${publicador.prop.nombreRespuestas}
</prop>
</props>
</property>
</bean>
<bean id="utils" class="com.bursatec.publicador.utils.ArchivosUtils">
</bean>
<jaxws:client id="servicioWeb"
serviceClass="com.bursatec.publicador.web.services.Servicios"
address="${publicador.prop.servicioWeb}" >
<jaxws:properties>
<entry key="mtom-enabled" value="true"/>
</jaxws:properties>
</jaxws:client>
<!-- ========================= Definicion de objetos del publicador
cliente ============ -->
</beans>
This is part of my ws definition the service called "enviaCorreo":
<wsdl:definitions name="ServiciosWeb"
targetNamespace="http://aplicaciones.bmv.com.mx">
−
<wsdl:types>
−
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified"
targetNamespace="http://aplicaciones.bmv.com.mx">
<xs:element name="encriptaPDF" type="tns:encriptaPDF"/>
<xs:element name="encriptaPDFResponse" type="tns:encriptaPDFResponse"/>
<xs:element name="enviaArchivoEmisnet" type="tns:enviaArchivoEmisnet"/>
<xs:element name="enviaArchivoEmisnetResponse"
type="tns:enviaArchivoEmisnetResponse"/>
<xs:element name="enviaArchivos" type="tns:enviaArchivos"/>
<xs:element name="enviaArchivosResponse" type="tns:enviaArchivosResponse"/>
<xs:element name="enviaCorreo" type="tns:enviaCorreo"/>
<xs:element name="enviaCorreoResponse" type="tns:enviaCorreoResponse"/>
−
<xs:complexType name="enviaArchivoEmisnet">
−
<xs:sequence>
<xs:element name="arg0" type="xs:int"/>
</xs:sequence>
</xs:complexType>
−
<xs:complexType name="enviaArchivoEmisnetResponse">
−
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="return"
type="tns:ArchivoEmisnetVO"/>
</xs:sequence>
</xs:complexType>
−
<xs:complexType name="ArchivoEmisnetVO">
−
<xs:sequence>
<xs:element minOccurs="0" name="archivo" type="xs:base64Binary"/>
<xs:element minOccurs="0" name="autorizado" type="xs:string"/>
<xs:element minOccurs="0" name="categoria" type="xs:int"/>
<xs:element minOccurs="0" name="creadoPor" type="xs:string"/>
<xs:element minOccurs="0" name="cveEmpresaOrigen" type="xs:string"/>
<xs:element minOccurs="0" name="cveSerie" type="xs:string"/>
<xs:element minOccurs="0" name="fechaCreacion" type="xs:dateTime"/>
<xs:element minOccurs="0" name="fechaModificacion" type="xs:dateTime"/>
<xs:element minOccurs="0" name="folioSobre" type="xs:int"/>
<xs:element minOccurs="0" name="idArchivo" type="xs:int"/>
<xs:element minOccurs="0" name="idEmpresaOrigen" type="xs:int"/>
<xs:element minOccurs="0" name="idPrefijo" type="xs:int"/>
<xs:element minOccurs="0" name="modificadoPor" type="xs:string"/>
<xs:element minOccurs="0" name="nombreArchivo" type="xs:string"/>
<xs:element minOccurs="0" name="nombrePrefijo" type="xs:string"/>
<xs:element minOccurs="0" name="prefijoAdjunto" type="xs:int"/>
<xs:element minOccurs="0" name="sistema" type="xs:string"/>
<xs:element minOccurs="0" name="subcategoria" type="xs:int"/>
<xs:element minOccurs="0" name="titulo" type="xs:string"/>
</xs:sequence>
</xs:complexType>
−
<xs:complexType name="enviaCorreo">
−
<xs:sequence>
<xs:element minOccurs="0" name="arg0" type="tns:Mensaje"/>
</xs:sequence>
</xs:complexType>
−
<xs:complexType name="Mensaje">
−
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="archivosAdjuntos"
nillable="true" type="tns:Archivo"/>
<xs:element maxOccurs="unbounded" minOccurs="0" name="archivosEmbebidos"
nillable="true" type="tns:Archivo"/>
<xs:element minOccurs="0" name="asunto" type="xs:string"/>
<xs:element minOccurs="0" name="codificacion" type="xs:string"/>
<xs:element minOccurs="0" name="contenido" type="xs:string"/>
<xs:element maxOccurs="unbounded" minOccurs="0" name="destinatarios"
nillable="true" type="xs:string"/>
<xs:element maxOccurs="unbounded" minOccurs="0" name="destinatariosBcc"
nillable="true" type="xs:string"/>
<xs:element maxOccurs="unbounded" minOccurs="0" name="destinatariosCc"
nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="direccionRemitente" type="xs:string"/>
<xs:element minOccurs="0" name="direcionRespuestas" type="xs:string"/>
<xs:element minOccurs="0" name="nombreRemitente" type="xs:string"/>
<xs:element minOccurs="0" name="nombreRespuestas" type="xs:string"/>
<xs:element minOccurs="0" name="tipoContenido" type="xs:string"/>
</xs:sequence>
</xs:complexType>
−
<xs:complexType name="Archivo">
−
<xs:sequence>
<xs:element minOccurs="0" name="data"
ns1:expectedContentTypes="application/octet-stream" type="xs:base64Binary"/>
<xs:element minOccurs="0" name="nombreArchivo" type="xs:string"/>
</xs:sequence>
</xs:complexType>
Also my files sized are from: 952 bytes and max. size< 3 MB
Thanks in advance
See you soon
JAIME IVAN OLVERA SEGURA
ESPECIALISTA SISTEMAS DE EMISORAS
SOPORTE A EMISORAS
TEL. +52 (55)53-42-93-30
NEXTEL. +52 (55)42-04-96-54
CEL. +52 (55)20-37-77-20
[email protected]
LISTA DE SOPORTE:
[email protected]