Fix DBCFX_SM_678 - Riadattata la chiamata ws EsitoVerificaCodiceSessione esposto da NOW in SOAP over HTTPS

This commit is contained in:
vincenzofariello
2024-05-28 08:40:20 +02:00
parent 70b5c57672
commit 214999da3d
9 changed files with 389 additions and 62 deletions

View File

@@ -59,7 +59,7 @@
<property name="wsdev.pitagora.building.path" value="${wsdev.home}/pitagora/building" />
<property name="wsdev.pitagora.donor.building.path" value="${wsdev.home}/pitagora/donor/building" />
<!-- Per sviluppo WS DBC Server -->
<!-- Per sviluppo WS DBC Server -->
<property name="wsdev.home" value="${project.home}/wsdbcfx" />
<property name="wsdev.wsdl.home" value="${wsdev.home}/wsdl" />
<property name="wsdev.wssrc.path" value="${dbcfx.src.path}"/>
@@ -94,7 +94,6 @@
<property name="wsdev.crmbwirelinevoipservice.war.name" value="CRMWirelineVOIPService"/>
<property name="wsdev.crmbdonorservice.war.name" value="EsitoVerificaCSDonorService"/>
<!-- Per sviluppo WS NOW - CheckRetailPlatform-->
<property name="wsdev.wsdl.now.path" value="${wsdev.wsdl.home}/now" />
<property name="wsdev.now.building.path" value="${wsdev.home}/now/building" />
@@ -168,7 +167,7 @@
<path id="wspitagora.client.class.path">
<pathelement path="${wspitagora.client.wsdl.position}/${output.wspitagora.client}"/>
</path>
<!-- Per sviluppo client WS pitagora DONOR -->
<!-- Per sviluppo client WS pitagora DONOR -->
<property name="wspitagora.clientdev.home.donor" value="${project.home}/dbcfx/wspitagora" />
<property name="wspitagora.client.wsdl.position.donor" value="${wspitagora.clientdev.home.donor}/client" />
<property name="output.wspitagora.client.donor" value="${wspitagora.clientdev.home.donor}/client" />
@@ -228,8 +227,6 @@
<property name="wscrm.voip.handler.chain.file" value="${wscrm.client.class.position}/voip_portin_handler.config.xml"/>
<property name="wscrm.donor.handler.chain.file" value="${wscrm.client.class.position}/esitoverificacsdonor_handler.config.xml"/>
<!-- Per sviluppo WS Client CheckRetailPlatform -->
<property name="wsnow.clientdev.home" value="${project.home}/wsdbcfx" />
<property name="wsnow.client.wsdl.position" value="${wsnow.clientdev.home}/wsdl/now" />
@@ -309,11 +306,20 @@
<!-- Per sviluppo client WS RispostaVerificaEsitoFase2 esposto da NOW -->
<property name="wsnow.clientdev.rispveresitofase2.home" value="${project.home}/wsdbcfx/wsdl/now/rispostaverificaesitofase2" />
<property name="wsnow.client.rispveresitofase2.wsdl.position" value="${wsnow.clientdev.rispveresitofase2.home}/client" />
<property name="wsnow.client.rispveresitofase2.wsdl.file" value="${wsnow.client.rispveresitofase2.wsdl.position}/RispostaVerificaEsitoFase2_concrete.wsdl" />
<property name="wsnow.client.rispveresitofase2.dir" value="${wsnow.client.rispveresitofase2.wsdl.position}/rispostaverificaesitofase2" />
<property name="wsnow.client.rispveresitofase2.src" value="${wsnow.client.rispveresitofase2.dir}/src" />
<property name="wsnow.client.rispveresitofase2.jar" value="${wsnow.clientdev.rispveresitofase2.home}/jar" />
<property name="wsnow.client.rispveresitofase2.wsdl.file" value="${wsnow.client.rispveresitofase2.wsdl.position}/RispostaVerificaEsitoFase2_concrete.wsdl" />
<property name="wsnow.client.rispveresitofase2.dir" value="${wsnow.client.rispveresitofase2.wsdl.position}/rispostaverificaesitofase2" />
<property name="wsnow.client.rispveresitofase2.src" value="${wsnow.client.rispveresitofase2.dir}/src" />
<property name="wsnow.client.rispveresitofase2.jar" value="${wsnow.clientdev.rispveresitofase2.home}/jar" />
<!-- Fine client WS RispostaVerificaEsitoFase2 -->
<!-- Per sviluppo client WS Risposta EsitoVerificaCodiceSessione Fase2 Del.82 Consumer esposto da NOW -->
<property name="wsnow.clientdev.esitoverificacodicesessionefase2.home" value="${project.home}/wsdbcfx/wsdl/now/esitoverificacodicesessionefase2" />
<property name="wsnow.client.esitoverificacodicesessionefase2.wsdl.position" value="${wsnow.clientdev.esitoverificacodicesessionefase2.home}/client" />
<property name="wsnow.client.esitoverificacodicesessionefase2.wsdl.file" value="${wsnow.client.esitoverificacodicesessionefase2.wsdl.position}/NOWEsitoVerificaCodiceSessione_concrete.wsdl" />
<property name="wsnow.client.esitoverificacodicesessionefase2.dir" value="${wsnow.client.esitoverificacodicesessionefase2.wsdl.position}/esitoverificacodicesessionefase2" />
<property name="wsnow.client.esitoverificacodicesessionefase2.src" value="${wsnow.client.esitoverificacodicesessionefase2.dir}/src" />
<property name="wsnow.client.esitoverificacodicesessionefase2.jar" value="${wsnow.clientdev.esitoverificacodicesessionefase2.home}/jar" />
<!-- Fine client WS Risposta EsitoVerificaCodiceSessione Fase2 Del.82 Consumer esposto da NOW -->
<!-- Per sviluppo client WS DBSS (CustomerLocationQuery) -->
<property name="wsdbss.clientdev.customerlocationquery.home" value="${project.home}/wsdbcfx/wsdl/dbss/CustomerLocationQuery" />
@@ -556,7 +562,7 @@
<file name="Castor-DbcFX2CRMRespVerifiche.jar" />
<file name="Castor-DbcFX2CRMReqAggiuntiviPBX.jar" />
<file name="Castor-DbcFX2CRMRespAggiuntiviPBX.jar" />
<file name="WSNOWEsitoVerificheCodSessioneCommon.jar" />
<file name="dbcfx-now-esitoverificacodicesessionefase2-ws-client.jar" />
</filelist>
<!-- LIB per la compilazione WS CRM-A -->
@@ -773,7 +779,7 @@ Se ne e' gia' stata fatta una personalizzazione verra' persa
</jar>
<copy file="${wspitagora.client.jar}/deploy_${startWsPitagoraClient.DSTAMP}_${startWsPitagoraClient.TSTAMP}/dbcfx-pitagora-ws-client.jar" todir="${dbcfx.ear.path}/res/APP-INF/lib"/>
</target>
<!-- CLIENT PITAGORA DONOR -->
<!-- CLIENT PITAGORA DONOR -->
<target name="build-ws-pitagora-client-donor" depends="wspitagoraclean" if="do.clientScaffolding">
<clientgen wsdl="${wspitagora.client.wsdl.position.donor}/VerificaEsitoFaseDue.wsdl"
destDir="${wspitagora.client.class.position.donor}/source"
@@ -988,9 +994,40 @@ Se ne e' gia' stata fatta una personalizzazione verra' persa
<copy file="${wsnow.client.rispveresitofase2.jar}/deploy_response_${startWsNowClient.DSTAMP}_${startWsNowClient.TSTAMP}/dbcfx-now-rispveresitofase2-ws-client.jar"
todir="${dbcfx.ear.path}/res/APP-INF/lib" />
</target>
<!-- FINE CLIENT WEB SERVICE NOW (RispostaVerificaEsitoFase2) -->
<!-- FINE CLIENT WEB SERVICE NOW (RispostaVerificaEsitoFase2) -->
<!-- CLIENT WEB SERVICE ESPOSTO DA NOW - EsitoVerificaCodiceSessione Fase2 Del.82 Consumer -->
<target name="wsesitoverificacodicesessionefase2clean" if="do.clientScaffolding" depends="chiediconferma-ws-client">
<delete dir="${wsnow.client.esitoverificacodicesessionefase2.dir}"/>
<mkdir dir="${wsnow.client.esitoverificacodicesessionefase2.dir}"/>
</target>
<target name="build-ws-now-esitoverificacodicesessionefase2-client" depends="wsesitoverificacodicesessionefase2clean" if="do.clientScaffolding">
<clientgen wsdl="${wsnow.client.esitoverificacodicesessionefase2.wsdl.file}"
destDir="${wsnow.client.esitoverificacodicesessionefase2.src}"
packageName="it.valueteam.now.webservices.client.esitoverificacodicesessionefase2"
handlerChainFile="${wsnow.client.esitoverificacodicesessionefase2.wsdl.position}/handler.config.xml"
/>
</target>
<target name="jar_dbcfx_now_esitoverificacodicesessionefase2_ws_client" depends="build-ws-now-esitoverificacodicesessionefase2-client">
<javac srcdir="${wsnow.client.esitoverificacodicesessionefase2.src}"
includes="**/*.java">
<classpath refid="ws.gen.all.classpath"/>
</javac>
<tstamp prefix="startWsNowClient"/>
<mkdir dir="${wsnow.client.esitoverificacodicesessionefase2.jar}/deploy_response_${startWsNowClient.DSTAMP}_${startWsNowClient.TSTAMP}"/>
<jar basedir="${wsnow.client.esitoverificacodicesessionefase2.src}"
destfile="${wsnow.client.esitoverificacodicesessionefase2.jar}/deploy_response_${startWsNowClient.DSTAMP}_${startWsNowClient.TSTAMP}/dbcfx-now-esitoverificacodicesessionefase2-ws-client.jar"
excludes="**/*.java">
</jar>
<copy file="${wsnow.client.esitoverificacodicesessionefase2.jar}/deploy_response_${startWsNowClient.DSTAMP}_${startWsNowClient.TSTAMP}/dbcfx-now-esitoverificacodicesessionefase2-ws-client.jar"
todir="${dbcfx.ear.path}/res/APP-INF/lib" />
</target>
<!-- FINE CLIENT WEB SERVICE ESPOSTO DA NOW - EsitoVerificaCodiceSessione Fase2 Del.82 Consumer -->
<!-- CLIENT WEB SERVICE esposto da NOW - CheckNP -->
<target name="wsnowchecknpclean" if="do.clientScaffolding" depends="chiediconferma-ws-client">
<delete dir="${wsdbss.client.now.checknp.dir}"/>
@@ -1988,31 +2025,6 @@ Se ne e' gia' stata fatta una personalizzazione verra' persa
</target>
<!-- FINE TARGET CREAZIONE ARTEFATTI SERVER PER WS VERSO NOW -->
<!-- INIZIO TARGET CREAZIONE ARTEFATTI CLIENT PER WS ESITO VERIFICHE SESSIONE VERSO NOW -->
<target name="WSEsitoVerificheCodSessioneJWS" if="do.wsartifacts" depends="chiediconferma-ws-artifact, init">
<delete file="${wsdev.now.building.path}/NOWEsitoVerificaCodiceSessione_concrete_wsdl.jar"/>
<wsdlc
srcWsdl="${wsdev.wsdl.now.path}/NOWEsitoVerificaCodiceSessione_concrete.wsdl"
destJwsDir="${wsdev.now.building.path}"
destImplDir="${wsdev.wssrc.path}"
packageName="it.valueteam.gnp.ws.now"/>
<!-- Compila i sorgenti e impacchetta le classi in un jar allo scopo di utilizzarlo con Eclipse -->
<mkdir dir="${wsdev.now.building.path}/temp" />
<unzip src="${wsdev.now.building.path}/NOWEsitoVerificaCodiceSessione_concrete_wsdl.jar" dest="${wsdev.now.building.path}/temp" />
<javac srcdir="${wsdev.now.building.path}/temp" includes="**/*.java">
<classpath refid="ws.gen.all.classpath"/>
</javac>
<jar destfile="${wsdev.now.building.path}/WSNOWEsitoVerificheCodSessioneCommon.jar">
<fileset dir="${wsdev.now.building.path}/temp"/>
</jar>
<delete dir="${wsdev.now.building.path}/temp" />
</target>
<!-- FINE TARGET CREAZIONE ARTEFATTI CLIENT PER WS VERSO NOW -->
<!-- INIZIO TARGET CREAZIONE ARTEFATTI SERVER PER WS ESITOPRENOTIFICAUSCITAMGMT DA DBSS -->
<target name="WSEsitoPrenotificaUscitaMgmtJWS" if="do.wsartifacts" depends="chiediconferma-ws-artifact, init">
<delete file="${wsdev.dbss.prenotifica.building.path}/EsitoPrenotificaUscitaMgmt_wsdl.jar"/>

View File

@@ -0,0 +1,8 @@
@set ANT_HOME=apache-ant-1.9.2
@set JAVA_HOME=C:/Program Files/Java/jdk1.6.0_45
@set PATH=%ANT_HOME%/bin;%JAVA_HOME%/bin
@set ANT_OPTS=-Xms512m -Xmx512m
@call ant -buildfile build.xml jar_dbcfx_now_esitoverificacodicesessionefase2_ws_client
@pause

View File

@@ -1,6 +1,6 @@
package it.valueteam.gnp.systemcontroller.formatcontroller.now;
import java.rmi.RemoteException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
@@ -11,7 +11,6 @@ import java.util.List;
import javax.transaction.UserTransaction;
import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;
import javax.xml.rpc.Stub;
import com.tim.now.xsd.now_esitoverificacodicesessione.Enum_CheckSessione_ESITO;
import com.tim.now.xsd.now_esitoverificacodicesessione.EsitoVerificaCodiceSessione;
@@ -21,11 +20,9 @@ import it.telecomitalia.soa.soap.soapheader.InteractionDateType;
import it.valueteam.gnp.dao.db.hb.*;
import it.valueteam.gnp.manager.RequestManagerDonor82;
import it.valueteam.gnp.systemcontroller.dbcfxgo.DbcfxgoController;
import it.valueteam.gnp.utility.DateUtils;
import it.valueteam.gnp.utility.Resources;
import it.valueteam.gnp.ws.now.EsitoVerificaCodiceSessione_PortType;
import it.valueteam.gnp.ws.now.EsitoVerificaCodiceSessione_PortType_Stub;
import it.valueteam.gnp.ws.now.EsitoVerificaCodiceSessione_Service_Impl;
import it.valueteam.gnp.ws.now.esitoverificacodicesessionefase2.EsitoVerificaCodiceSessioneFase2NowClient;
import org.hibernate.Hibernate;
import org.hibernate.criterion.Restrictions;
import org.hibernate.criterion.SimpleExpression;
@@ -394,6 +391,7 @@ public class NowController extends SystemController {
gnpNowDonorOut.setEsito("KO");
gnpNowDonorOut.setCodiceMotivazione("Y19");
gnpNowDonorOut.setMotivazione("Codice Sessione Inesistente");
gnpNowDonorOut.setDataNotifica(new Date());
}
GnpNowD82RichiesteOutDAO nowD82RichiesteOutDAO = new GnpNowD82RichiesteOutDAO();
@@ -403,7 +401,6 @@ public class NowController extends SystemController {
inserisciNotificaInCoda(message);
log.write("9999", "INSERITO SULLA CODA MESSAGEQUEUENOWOUT:" + uniqueIdNowDonorOut);
} catch (Exception ex) {
log.error(ex, "verificaValiditaSessioneD82");
throw ex;
@@ -924,7 +921,9 @@ public class NowController extends SystemController {
log.write("9999", "elaboraNowDonorOut per :[" + nowDonorOut.getUniqueId() + "]");
com.tim.now.xsd.now_esitoverificacodicesessione.Request request = new com.tim.now.xsd.now_esitoverificacodicesessione.Request();
EsitoVerificaCodiceSessioneFase2NowClient nowClient = new EsitoVerificaCodiceSessioneFase2NowClient();
EsitoVerificaCodiceSessione esito = new EsitoVerificaCodiceSessione();
esito.setCODICE_ORDINE_WHS(nowDonorOut.getCodiceOrdineWhs());
esito.setCODICE_MOTIVAZIONE(nowDonorOut.getCodiceMotivazione());
esito.setMOTIVAZIONE(nowDonorOut.getMotivazione());
@@ -934,33 +933,25 @@ public class NowController extends SystemController {
request.setEsitoVerificaCodiceSessione(esito);
EsitoVerificaCodiceSessione_Service_Impl service = new EsitoVerificaCodiceSessione_Service_Impl();
EsitoVerificaCodiceSessione_PortType endPoint;
endPoint = service.getEsitoVerificaCodiceSessioneSOAP();
String timeOutStr = (String) Resources.getTIMEOUT_WS_NOW_ESITO_VERIFICA_CS();
((EsitoVerificaCodiceSessione_PortType_Stub) endPoint)._setProperty("javax.xml.rpc.service.endpoint.address", Resources.getURL_WS_NOW_ESITO_VERIFICA_CS());
((EsitoVerificaCodiceSessione_PortType_Stub) endPoint)._setProperty("weblogic.wsee.transport.connection.timeout", Integer.parseInt(timeOutStr));
HeaderTypeHolder headerTypeHolder = new HeaderTypeHolder();
HeaderType header = new HeaderType();
Date date = new Date();
header.setSourceSystem("DBCFX");
InteractionDateType dateType = new InteractionDateType();
dateType.setDate(new SimpleDateFormat("yyyy-MM-dd").format(date));
dateType.setTime(new SimpleDateFormat("HH:mm:ss").format(date));
header.setInteractionDate(dateType);
header.setSourceSystem("DBCFX");
header.setTransactionID(new TID().toString());
header.setBusinessID(new TID().toString());
String businessId = new TID().toString();
header.setBusinessID(businessId);
header.setMessageID(new TID().toString());
headerTypeHolder.value = header;
header.setTransactionID(new TID().toString());
try {
if ("KO".equals(nowDonorOut.getEsito())) {
Response response = endPoint.invoke(request, headerTypeHolder);
log.write("9999", "Risposta OK da now, ID_NOTIFICA: " + response.getID_NOTIFICA());
log.write("9999", "Chiamata verso Now EsitoVerificaCodiceSessione ws - businessId: " + businessId);
Response response = nowClient.invoke(request, header);
log.write("9999", "Risposta EsitoVerificaCodiceSessione ws OK da Now, businessId: " + businessId + " ID_NOTIFICA: " + response.getID_NOTIFICA());
} else {
log.write("9999", "ESITO VERIFICHE DBCFX OK da now, NON INVIO ESITO A NOW PER ID_NOTIFICA: " + nowDonorOut.getIdNotifica());
log.write("9999", "ESITO VERIFICHE DBCFX OK, NON INVIO ESITO A NOW PER ID_NOTIFICA: " + nowDonorOut.getIdNotifica());
}
} catch (Exception e) {
log.write("9999", "RICHIESTA DONOR OUT con UNIQUE_ID " + nowDonorOut.getUniqueId() + " ANDATA IN ERRORE VERSO NOW: " + e.getMessage());

View File

@@ -0,0 +1,226 @@
package it.valueteam.gnp.ws.now.esitoverificacodicesessionefase2;
import com.tim.now.xsd.now_esitoverificacodicesessione.Enum_Response_ESITO;
import com.tim.now.xsd.now_esitoverificacodicesessione.Request;
import com.tim.now.xsd.now_esitoverificacodicesessione.Response;
import it.telecomitalia.soa.soap.soapheader.HeaderType;
import it.valueteam.gnp.log.Loggable;
import it.valueteam.gnp.log.ProcessLogger;
import it.valueteam.gnp.obj.LogInfo;
import it.valueteam.gnp.obj.LogProcess;
import it.valueteam.gnp.utility.Func;
import it.valueteam.gnp.utility.Resources;
import it.valueteam.gnp.ws.utlities.WSUtils;
import org.apache.http.Header;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicHeader;
import javax.ejb.CreateException;
import javax.net.ssl.SSLContext;
import javax.xml.soap.*;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.InputStreamReader;
import java.util.concurrent.TimeUnit;
public class EsitoVerificaCodiceSessioneFase2NowClient implements Loggable {
private String url;
private int timeOut;
private static final int defaultTimeOut = 30000;
protected ProcessLogger log;
protected String codiceProcesso = "SH"; // come da GNP_ANAGRAFICA_PROCESSO
protected String versione = "1.0.0.0";
public EsitoVerificaCodiceSessioneFase2NowClient() throws Exception {
try {
LogProcess logProcess = new LogProcess();
logProcess.setCodice(codiceProcesso);
logProcess.setProcess(this);
log = new ProcessLogger(logProcess);
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Errore nella creazione del ProcessLogger, classe:" + EsitoVerificaCodiceSessioneFase2NowClient.class + " - " + ex.toString());
throw new CreateException();
}
log.write("0001", " versione " + versione);
url = Resources.getURL_WS_NOW_ESITO_VERIFICA_CS();
if ("".equals(url)) {
log.write("0003", "");
throw new Exception("Errore in creazione client - impossibile recuperare url del ws da properties");
}
String timeOutStr = Resources.getTIMEOUT_WS_NOW_ESITO_VERIFICA_CS();
log.write("9999", " now client - url: " + url + " - timeOut: " + timeOutStr);
try {
timeOut = Integer.parseInt(timeOutStr);
} catch (NumberFormatException nfe) {
log.write("9999", " impossibile recuperare property timeout - impostato valore di default: " + defaultTimeOut);
timeOut = defaultTimeOut;
}
}
public Response invoke(Request request, HeaderType header) throws Exception{
log.write("9999", "EsitoVerificaCodiceSessione - soapAction='Invoke' start");
CloseableHttpClient client = null;
CloseableHttpResponse response = null;
StringBuilder req = new StringBuilder();
StringBuilder resp = new StringBuilder();
String bid = header.getBusinessID();
try {
SSLContext sslContext = WSUtils.createSSLContext("SSL");
if(sslContext != null) {
SSLConnectionSocketFactory scf = WSUtils.createSSLConnectionSocketFactory(sslContext,
Resources.NOW_SUPPORTED_PROTOCOLS(), Resources.NOW_SUPPORTED_CIPHER_SUITES());
client = HttpClients.custom().useSystemProperties().setSSLSocketFactory(scf).setConnectionTimeToLive(timeOut,
TimeUnit.MILLISECONDS).build();
} else {
client = HttpClients.custom().useSystemProperties().setConnectionTimeToLive(timeOut, TimeUnit.MILLISECONDS).build();
}
HttpPost httpPost = new HttpPost(url);
// Set Header HTTP Post
Header[] headers = new BasicHeader[2];
headers[0] = new BasicHeader("Content-Type", "text/xml; charset=UTF-8");
headers[1] = new BasicHeader("SOAPAction", "Invoke");
httpPost.setHeaders(headers);
// Set SOAPBody HTTP Post
StringEntity lEntity = new StringEntity(createHttpRequest(header, request));
httpPost.setEntity(lEntity);
// Loggata request EsitoVerificaCodiceSessione inviata a Now
log.write("9999", "businessId: " + bid + " - [EsitoVerificaCodiceSessione] - Inizio Log Request");
BufferedReader requestReader = new BufferedReader(new InputStreamReader(lEntity.getContent()));
String lineReq;
while ((lineReq = requestReader.readLine()) != null) {
req.append(lineReq).append('\n');
}
log.write("9999", "businessId: " + bid + " - " + req.toString());
log.write("9999", "businessId: " + bid + " - [EsitoVerificaCodiceSessione] - Fine Log Request");
response = client.execute(httpPost);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line;
while ((line = rd.readLine()) != null) {
resp.append(line).append('\n');
}
if (response.getStatusLine().getStatusCode() != 200) {
log.write("9999", "businessId: " + bid + " - [EsitoVerificaCodiceSessione] - Inizio Log Error");
log.write("9999", "businessId: " + bid + " - " + resp.toString());
log.write("9999", "businessId: " + bid + " - [EsitoVerificaCodiceSessione] - Fine Log Error");
throw new Exception(header.getTransactionID() + " - Soap fault exception");
}
// Loggata response EsitoVerificaCodiceSessione ricevuta da Now
log.write("9999", "businessId: " + bid + " - [EsitoVerificaCodiceSessione] - Inizio Log Response");
log.write("9999", "businessId: " + bid + " - " + resp.toString());
log.write("9999", "businessId: " + bid + " - [EsitoVerificaCodiceSessione] - Fine Log Response");
Response ack = getRispostaFromHttp(resp.toString());
log.write("9999", "EsitoVerificaCodiceSessione - soapAction='Invoke' end");
return ack;
} catch (Exception e) {
log.write("0003", "businessId: " + bid + " - Eccezione durante l'invocazione del ws [EsitoVerificaCodiceSessione.Invoke]: " + e);
throw e;
} finally {
try {
if (client != null) {
client.close();
}
if (response != null) {
response.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
private String createHttpRequest(HeaderType header, Request request) throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage soapMessage = messageFactory.createMessage();
SOAPPart soapPart = soapMessage.getSOAPPart();
String serverURI = "http://telecomitalia.it/SOA/SOAP/SOAPHeader";
String serverURI2 = "http://www.tim.com/NOW/xsd/NOW_EsitoVerificaCodiceSessione/";
SOAPEnvelope envelope = soapPart.getEnvelope();
// SOAPHeader soapHeader = envelope.getHeader();
SOAPBody soapBody = envelope.getBody();
SOAPBodyElement hElement = soapBody.addBodyElement(envelope.createName("Header", "soap", serverURI));
hElement.addChildElement("sourceSystem", "soap").addTextNode(header.getSourceSystem());
SOAPElement interactionDate = hElement.addChildElement("interactionDate", "soap");
interactionDate.addChildElement("Date", "soap").addTextNode(header.getInteractionDate().getDate());
interactionDate.addChildElement("Time", "soap").addTextNode(header.getInteractionDate().getTime());
hElement.addChildElement("businessID", "soap").addTextNode(header.getBusinessID());
hElement.addChildElement("messageID", "soap").addTextNode(header.getMessageID());
hElement.addChildElement("transactionID", "soap").addTextNode(header.getTransactionID());
SOAPBodyElement element = soapBody.addBodyElement(envelope.createName("Request", "now", serverURI2));
SOAPElement elementEsito = element.addChildElement("EsitoVerificaCodiceSessione", "now");
elementEsito.addChildElement("CODICE_ORDINE_WHS", "now").addTextNode(request.getEsitoVerificaCodiceSessione().getCODICE_ORDINE_WHS());
elementEsito.addChildElement("ID_NOTIFICA", "now").addTextNode(request.getEsitoVerificaCodiceSessione().getID_NOTIFICA());
if(!Func.isNull(request.getEsitoVerificaCodiceSessione().getDATA_NOTIFICA()))
elementEsito.addChildElement("DATA_NOTIFICA", "now").addTextNode(request.getEsitoVerificaCodiceSessione().getDATA_NOTIFICA());
elementEsito.addChildElement("ESITO", "now").addTextNode(String.valueOf(request.getEsitoVerificaCodiceSessione().getESITO()));
elementEsito.addChildElement("CODICE_MOTIVAZIONE", "now").addTextNode(request.getEsitoVerificaCodiceSessione().getCODICE_MOTIVAZIONE());
elementEsito.addChildElement("MOTIVAZIONE", "now").addTextNode(request.getEsitoVerificaCodiceSessione().getMOTIVAZIONE());
if(!Func.isNull(request.getEsitoVerificaCodiceSessione().getNOTE()))
elementEsito.addChildElement("NOTE", "now").addTextNode(request.getEsitoVerificaCodiceSessione().getNOTE());
soapMessage.saveChanges();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
soapMessage.writeTo(baos);
return baos.toString();
}
private Response getRispostaFromHttp(String risposta) throws Exception {
SOAPBody soapBody = WSUtils.getSOAPBody(risposta);
Response ack = new Response();
org.w3c.dom.Node nMaster = soapBody.getChildNodes().item(0);
if(nMaster != null) {
org.w3c.dom.Node n = WSUtils.getChildByName(nMaster, "ID_NOTIFICA");
if (n != null) {
ack.setID_NOTIFICA(n.getFirstChild().getNodeValue());
}
n = WSUtils.getChildByName(nMaster, "ESITO");
if (n != null) {
ack.setESITO(Enum_Response_ESITO.fromValue(n.getFirstChild().getNodeValue()));
}
}
return ack;
}
/**
* Implements method in Loggable public Interface
* @return
* @throws Exception
*/
public LogInfo getLogInfo() throws Exception {
LogInfo logInfo = new LogInfo();
logInfo.setProcess(getClass().getName());
logInfo.setLogPath(Resources.getLogPath());
logInfo.setTypeInfo(Resources.getTypeInfo());
logInfo.setTypeDebug(Resources.getTypeDebug());
logInfo.setTypeError(Resources.getTypeError());
return logInfo;
}
}

View File

@@ -0,0 +1,81 @@
package it.valueteam.gnp.ws.now.esitoverificacodicesessionefase2;
import it.valueteam.gnp.log.Loggable;
import it.valueteam.gnp.log.ProcessLogger;
import it.valueteam.gnp.obj.LogProcess;
import it.valueteam.gnp.systemcontroller.formatcontroller.crm.WSSOAPHandler;
import javax.xml.rpc.handler.MessageContext;
import javax.xml.rpc.handler.soap.SOAPMessageContext;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPMessage;
import java.io.ByteArrayOutputStream;
public class EsitoVerificaCodiceSessioneSOAPHandler extends WSSOAPHandler implements Loggable {
protected ProcessLogger log;
public EsitoVerificaCodiceSessioneSOAPHandler() throws Exception {
LogProcess logProcess = new LogProcess();
logProcess.setCodice(codiceProcesso);
logProcess.setProcess(this);
log = new ProcessLogger(logProcess);
}
public boolean handleRequest(MessageContext context) {
SOAPMessageContext soapMsgCtx = (SOAPMessageContext) context;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
SOAPMessage message = soapMsgCtx.getMessage();
SOAPHeader header = message.getSOAPHeader();
String bid = getBid(header);
log.write("9999",bid + " - [EsitoVerificaCodiceSessioneSOAPHandler] - Inizio Log Request");
soapMsgCtx.getMessage().writeTo(baos);
log.write("9999",baos.toString());
log.write("9999",bid + " - [EsitoVerificaCodiceSessioneSOAPHandler] - Fine Log Request");
} catch (Exception ex) {
ex.printStackTrace();
return false;
}
return true;
}
public boolean handleResponse(MessageContext context) {
SOAPMessageContext soapMsgCtx = (SOAPMessageContext) context;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
SOAPHeader header = ((SOAPMessageContext) context).getMessage().getSOAPHeader();
String bid = getBid(header);
log.write("9999",bid + " - [EsitoVerificaCodiceSessioneSOAPHandler] - Inizio Log Response");
soapMsgCtx.getMessage().writeTo(baos);
log.write("9999",bid + " - "+baos.toString());
log.write("9999",bid + " - [EsitoVerificaCodiceSessioneSOAPHandler] - Fine Log Response");
} catch (Exception ex) {
ex.printStackTrace();
return false;
}
return true;
}
public boolean handleFault(MessageContext context) {
SOAPMessageContext soapMsgCtx = (SOAPMessageContext) context;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
SOAPMessage message = soapMsgCtx.getMessage();
SOAPHeader header = message.getSOAPHeader();
String bid = getBid(header);
log.write("9999",bid + " - [EsitoVerificaCodiceSessioneSOAPHandler] - Inizio Log Error");
soapMsgCtx.getMessage().writeTo(baos);
log.write("9999",bid + " - "+baos.toString());
log.write("9999",bid + " - [EsitoVerificaCodiceSessioneSOAPHandler] - Fine Log Error");
} catch (Exception ex) {
ex.printStackTrace();
return false;
}
return true;
}
}

View File

@@ -0,0 +1,9 @@
<weblogic-wsee-clientHandlerChain
xmlns="http://www.bea.com/ns/weblogic/90"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:j2ee="http://java.sun.com/xml/ns/j2ee">
<handler>
<j2ee:handler-name>EsitoVerificaCodiceSessioneSOAPHandler</j2ee:handler-name>
<j2ee:handler-class>it.valueteam.gnp.ws.now.esitoverificacodicesessionefase2.EsitoVerificaCodiceSessioneSOAPHandler</j2ee:handler-class>
</handler>
</weblogic-wsee-clientHandlerChain>