Añado los fuentes de java
This commit is contained in:
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Creado el 13-feb-07
|
||||
*
|
||||
* Para cambiar la plantilla para este archivo generado vaya a
|
||||
* Ventana>Preferencias>Java>Generaci�n de c�digo>C�digo y comentarios
|
||||
*/
|
||||
package com.tarisan.chipcard.tpvvs.webservicetrayicon;
|
||||
|
||||
import com.tarisan.chipcard.tpvvs.ws.*;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
/*import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Calendar;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.logging.Log;*/
|
||||
|
||||
import com.tarisan.chipcard.tpvvs.webservicetrayicon.messages.*;
|
||||
|
||||
import es.chipcard.util.SerClsFecha;
|
||||
|
||||
/**
|
||||
* @author jjrider
|
||||
*
|
||||
* Para cambiar la plantilla para este comentario de tipo generado vaya a
|
||||
* Ventana>Preferencias>Java>Generaci�n de c�digo>C�digo y comentarios
|
||||
*/
|
||||
public class ClienteServicioWeb extends Thread{
|
||||
|
||||
private Msg request=null;
|
||||
private ControladorRespuestas objController=null;
|
||||
private static java.io.File fMessagesDir=null;
|
||||
private int secuencial = 0;
|
||||
|
||||
private URL endPointURL=null;
|
||||
|
||||
private int nSegundosTimeout=60;
|
||||
|
||||
|
||||
|
||||
static{
|
||||
//System.setProperty("javax.net.ssl.trustStore","./conf/cacerts");
|
||||
///etc/java-6-sun/security/
|
||||
|
||||
//System.setProperty("javax.net.ssl.trustStore","/root/apache-tomcat-6.0.20/webapps/tarisan/WEB-INF/lib/cacerts");
|
||||
System.setProperty("javax.net.ssl.trustStore","/usr/share/tomcat/conf/cacerts");
|
||||
|
||||
System.out.println(System.getProperty("javax.net.ssl.trustStore"));
|
||||
System.setProperty("javax.net.ssl.trustStorePassword","changeit");
|
||||
}
|
||||
public ClienteServicioWeb(Msg msg,ControladorRespuestas objController,URL endPointURL)
|
||||
{
|
||||
request=msg;
|
||||
System.out.println(request.toString());
|
||||
this.objController=objController;
|
||||
this.endPointURL=endPointURL;
|
||||
start();
|
||||
}
|
||||
|
||||
public ClienteServicioWeb(Msg msg,ControladorRespuestas objController,URL endPointURL, int seq){
|
||||
request=msg;
|
||||
this.secuencial = seq;
|
||||
System.out.println(request.toString());
|
||||
this.objController=objController;
|
||||
this.endPointURL=endPointURL;
|
||||
start();
|
||||
}
|
||||
|
||||
public void run(){
|
||||
String sResponse=null;
|
||||
String sUniqueID=calculateUniqueId();
|
||||
try{
|
||||
SerClsChipCardWSPuntoEntradaSoapBindingStub service=new SerClsChipCardWSPuntoEntradaSoapBindingStub();
|
||||
service.setEndPoint(endPointURL );
|
||||
service.setTimeout(getSegundosTimeout()*1000);
|
||||
saveRequest(sUniqueID, this.secuencial);
|
||||
sResponse=service.requestService(request.toString());
|
||||
}catch(Exception err){
|
||||
err.printStackTrace();
|
||||
WebServiceTrayIcon.showErrorMessage("Web Service Tray Icon","No se obtuvo la respuesta a la peticion por motivo:"+err.getMessage());
|
||||
objController.recibeRespuesta(null);
|
||||
}
|
||||
if(sResponse!=null){
|
||||
try{
|
||||
saveResponse(sUniqueID,sResponse, this.secuencial);
|
||||
if(Tarisan.inserta_respuesta_oracle(sResponse, secuencial))
|
||||
System.out.println("Respuesta "+this.secuencial+" insertada OK en oracle. "+sResponse);
|
||||
else
|
||||
System.out.println("Respuesta "+this.secuencial+" NO insertada en oracle. "+sResponse);
|
||||
|
||||
}catch(Exception err){
|
||||
err.printStackTrace();
|
||||
}
|
||||
}
|
||||
objController.recibeRespuesta(sResponse);
|
||||
|
||||
}
|
||||
|
||||
public int getSegundosTimeout(){
|
||||
return nSegundosTimeout;
|
||||
}
|
||||
|
||||
public void setSegundosTimeout(int nValue){
|
||||
nSegundosTimeout=nValue;
|
||||
}
|
||||
|
||||
private String calculateUniqueId(){
|
||||
SerClsFecha fecha=new SerClsFecha();
|
||||
String sRetorno=fecha.toString("yyyyMMdd_HHmmssSSS");
|
||||
return sRetorno;
|
||||
}
|
||||
|
||||
protected void saveRequest(String sID, int secuencial){
|
||||
try{
|
||||
//System.out.println("Se va a guardar la peticion: "+getMessagesDir()+sID+"_"+secuencial+"_Request.xml");
|
||||
OutputStream fout=new BufferedOutputStream(new FileOutputStream(new File(getMessagesDir(),sID+"_"+secuencial+"_Request.xml")));
|
||||
request.saveToOutputStream(fout);
|
||||
fout.close();
|
||||
}catch(Exception err){err.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected void saveResponse(String sID,String sResponse, int secuencial){
|
||||
try{
|
||||
// <Tarjeta><num>803446000000081111111001</num><ver>
|
||||
//System.out.println("Se va a guardar la peticion: "+getMessagesDir()+sID+"_"+secuencial+"_Response.xml");
|
||||
OutputStream fout=new BufferedOutputStream(new FileOutputStream(new File(getMessagesDir(),sID+"_"+secuencial+"_Response.xml")));
|
||||
saveXMLToFile(fout,sResponse);
|
||||
}catch(Exception err){err.printStackTrace();}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void saveXMLToFile(OutputStream fout,String sXML){
|
||||
try{
|
||||
byte bRes[]=sXML.getBytes();
|
||||
fout.write(bRes);
|
||||
fout.close();
|
||||
}catch(Exception err){err.printStackTrace();}
|
||||
}
|
||||
|
||||
private java.io.File getMessagesDir(){
|
||||
if(fMessagesDir==null){
|
||||
fMessagesDir=new File("./messages/");
|
||||
}
|
||||
if(!fMessagesDir.exists()){
|
||||
fMessagesDir.mkdirs();
|
||||
}
|
||||
return fMessagesDir;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user