ConnettoreStresstest.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */




  20. package org.openspcoop2.pdd.core.connettori;

  21. import java.io.ByteArrayInputStream;
  22. import java.sql.Connection;
  23. import java.util.ArrayList;

  24. import org.openspcoop2.core.config.ResponseCachingConfigurazione;
  25. import org.openspcoop2.core.constants.Costanti;
  26. import org.openspcoop2.core.constants.CostantiConnettori;
  27. import org.openspcoop2.core.constants.CostantiLabel;
  28. import org.openspcoop2.core.id.IDSoggetto;
  29. import org.openspcoop2.core.registry.constants.CostantiRegistroServizi;
  30. import org.openspcoop2.message.OpenSPCoop2MessageFactory;
  31. import org.openspcoop2.message.OpenSPCoop2MessageParseResult;
  32. import org.openspcoop2.message.constants.MessageRole;
  33. import org.openspcoop2.pdd.config.DBManager;
  34. import org.openspcoop2.pdd.config.OpenSPCoop2Properties;
  35. import org.openspcoop2.pdd.config.Resource;
  36. import org.openspcoop2.pdd.mdb.ConsegnaContenutiApplicativi;
  37. import org.openspcoop2.protocol.engine.ProtocolFactoryManager;
  38. import org.openspcoop2.protocol.engine.builder.Imbustamento;
  39. import org.openspcoop2.protocol.engine.driver.ProfiloDiCollaborazione;
  40. import org.openspcoop2.protocol.engine.driver.RepositoryBuste;
  41. import org.openspcoop2.protocol.sdk.Busta;
  42. import org.openspcoop2.protocol.sdk.IProtocolFactory;
  43. import org.openspcoop2.protocol.sdk.Integrazione;
  44. import org.openspcoop2.protocol.sdk.config.ITraduttore;
  45. import org.openspcoop2.protocol.sdk.constants.RuoloMessaggio;
  46. import org.openspcoop2.protocol.sdk.state.StatefulMessage;
  47. import org.openspcoop2.utils.Utilities;
  48. import org.openspcoop2.utils.date.DateManager;
  49. import org.openspcoop2.utils.random.RandomUtilities;





  50. /**
  51.  * ConnettoreStresstest
  52.  *
  53.  * @author Andrea Poli (apoli@link.it)
  54.  * @author $Author$
  55.  * @version $Rev$, $Date$
  56.  */
  57. public class ConnettoreStresstest extends ConnettoreBase {

  58.     @Override
  59.     public String getProtocollo() {
  60.         return "HTTP";
  61.     }
  62.    
  63.     public static final String ENDPOINT_TYPE = "stresstest";
  64.    
  65.     public static final String LOCATION = "openspcoop2://stresstest";
  66.    

  67.     /* ********  F I E L D S  P R I V A T I  ******** */

  68.     private static final String HEADER_APPLICATIVO = "<thdr:headerApplicativo xmlns:thdr=\"http://example.org/test\" tipo=\"TEST\" soapenv:actor=\"http://example.org/test/actor\">\n"+
  69.                                                      "<identificativoDominio>ITALIA</identificativoDominio>\n"+
  70.                                                      "<thdr:identificatore>RISP@SERIAL@</thdr:identificatore>\n"+
  71.                                                      "</thdr:headerApplicativo>";
  72.    
  73.     private static final String SOAP_ENVELOPE_RISPOSTA =
  74.         "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
  75.         "   xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><soapenv:Header>@HDR@</soapenv:Header>";
  76.     private static final String SOAP_ENVELOPE_RISPOSTA_END =
  77.         "<soapenv:Body><prova>test</prova></soapenv:Body></soapenv:Envelope>";


  78.     private Resource resource = null;
  79.     private DBManager dbManager = null;
  80.    
  81.     public ConnettoreStresstest(){
  82.         super();
  83.         this.dbManager = DBManager.getInstance();
  84.     }
  85.    
  86.    
  87.     /* ********  METODI  ******** */

  88.     @Override
  89.     protected boolean initializePreSend(ResponseCachingConfigurazione responseCachingConfig, ConnettoreMsg request) {
  90.        
  91.         if(this.initialize(request, false, responseCachingConfig)==false){
  92.             return false;
  93.         }
  94.        
  95.         return true;
  96.        
  97.     }
  98.    
  99.     @Override
  100.     protected boolean send(ConnettoreMsg request) {
  101.        
  102.         // - Header Applicativo nella risposta
  103.         boolean headerApplicativoRisposta = false;
  104.         if(this.properties.get(CostantiConnettori.CONNETTORE_STRESS_TEST_HEADER_APPLICATIVO)!=null){
  105.             if("true".equalsIgnoreCase(this.properties.get(CostantiConnettori.CONNETTORE_STRESS_TEST_HEADER_APPLICATIVO).trim()))
  106.                 headerApplicativoRisposta = true;
  107.         }
  108.            
  109.         this.codice = 200;
  110.                
  111.         try{
  112.            
  113.             // SIMULAZIONE WRITE_TO
  114.            
  115.             org.apache.commons.io.output.NullOutputStream nullOutputStream = org.apache.commons.io.output.NullOutputStream.INSTANCE;
  116.             this.requestMsg.writeTo(nullOutputStream,true);
  117.             nullOutputStream.flush();
  118.             nullOutputStream.close();
  119.                
  120.             //this.response = request.getRequestMessage();
  121.             //java.io.FileOutputStream fout = new java.io.FileOutputStream("/dev/null");
  122.             //request.getRequestMessage().writeTo(fout,true);
  123.             //fout.flush();
  124.             //fout.close();
  125.            
  126.             this.dataRichiestaInoltrata = DateManager.getDate();
  127.            
  128.            
  129.            
  130.            
  131.             /* ------------  PostOutRequestHandler ------------- */
  132.             this.postOutRequest();
  133.            
  134.            
  135.            
  136.            
  137.            
  138.            
  139.            
  140.             // SLEEP
  141.             // Connettore custom, impostare nei parametri i tempi di sleep
  142.             if(request.getConnectorProperties()!=null){
  143. //              java.util.Enumeration<String> enValues = request.getConnectorProperties().keys();
  144. //              while (enValues.hasMoreElements()) {
  145. //                  String key = (String) enValues.nextElement();
  146. //                  System.out.println("KEY["+key+"]=["+request.getConnectorProperties().get(key)+"]");
  147. //              }
  148.                
  149.                 Object max = request.getConnectorProperties().get(CostantiConnettori.CONNETTORE_STRESS_TEST_SLEEP_MAX);
  150.                 Object min = request.getConnectorProperties().get(CostantiConnettori.CONNETTORE_STRESS_TEST_SLEEP_MIN);
  151.                 if(max!=null){
  152.                     int maxSleep = Integer.parseInt((String)max);
  153.                     int minSleep = 0;
  154.                     if(min!=null){
  155.                         minSleep = Integer.parseInt((String)min);
  156.                     }
  157.                     int sleep = minSleep + RandomUtilities.getRandom().nextInt(maxSleep-minSleep);
  158.                     if(sleep>1000){
  159.                         int count = sleep/1000;
  160.                         int resto = sleep%1000;
  161.                         this.logger.info("sleep "+sleep+"ms ...",false);
  162.                         for (int i = 0; i < count; i++) {
  163.                             Utilities.sleep(1000);
  164.                         }
  165.                         Utilities.sleep(resto);
  166.                         this.logger.info("sleep "+sleep+"ms terminated", false);
  167.                     }else{
  168.                         this.logger.info("sleep "+sleep+"ms ...", false);
  169.                         Utilities.sleep(sleep);
  170.                         this.logger.info("sleep "+sleep+"ms terminated", false);
  171.                     }
  172.                 }
  173.                 else{
  174.                     Object sleepConstant = request.getConnectorProperties().get(CostantiConnettori.CONNETTORE_STRESS_TEST_SLEEP);
  175.                     if(sleepConstant!=null){
  176.                         int millisecond = Integer.parseInt((String)sleepConstant);
  177.                         if(millisecond>1000){
  178.                             int count = millisecond/1000;
  179.                             int resto = millisecond%1000;
  180.                             this.logger.info("sleep "+millisecond+"ms ...", false);
  181.                             for (int i = 0; i < count; i++) {
  182.                                 Utilities.sleep(1000);
  183.                             }
  184.                             Utilities.sleep(resto);
  185.                             this.logger.info("sleep "+millisecond+"ms terminated", false);
  186.                         }else{
  187.                             this.logger.info("sleep "+millisecond+"ms ...", false);
  188.                             Utilities.sleep(millisecond);
  189.                             this.logger.info("sleep "+millisecond+"ms terminated", false);
  190.                         }
  191.                     }
  192.                 }
  193.             }
  194.            
  195.            
  196.            
  197.            
  198.            
  199.            
  200.             /* ------------  PreInResponseHandler ------------- */
  201.             this.preInResponse();
  202.            
  203.            
  204.            
  205.             // Lettura risposta parametri NotifierInputStream per la risposta
  206.             org.openspcoop2.utils.io.notifier.NotifierInputStreamParams notifierInputStreamParams = null;
  207.             if(this.preInResponseContext!=null){
  208.                 notifierInputStreamParams = this.preInResponseContext.getNotifierInputStreamParams();
  209.             }
  210.            
  211.            
  212.             if(org.openspcoop2.protocol.sdk.constants.ProfiloDiCollaborazione.ONEWAY.equals(request.getBusta().getProfiloDiCollaborazione())){
  213.                 // se non devo generare un riscontro, non e' prevista una risposta
  214.                 if ( ! (request.getBusta().isConfermaRicezione() &&
  215.                         this.openspcoopProperties.isGestioneRiscontri(CostantiRegistroServizi.IMPLEMENTAZIONE_STANDARD))){
  216.                     return true; // non devo generare alcuna risposta
  217.                 }
  218.             }
  219.             String protocolHeader = this.buildProtocolHeader(request);
  220.             if(headerApplicativoRisposta){
  221.                 String hdrApplicativo = HEADER_APPLICATIVO.replace("@SERIAL@", DateManager.getTimeMillis()+"");
  222.                 protocolHeader = hdrApplicativo + "\n" + protocolHeader;
  223.             }
  224.             String messaggio = SOAP_ENVELOPE_RISPOSTA.replace("@HDR@", protocolHeader) + SOAP_ENVELOPE_RISPOSTA_END;
  225.             byte [] messaggioArray = messaggio.getBytes();
  226.            
  227.             ByteArrayInputStream bin = new ByteArrayInputStream(messaggioArray);
  228.             OpenSPCoop2MessageFactory messageFactory = org.openspcoop2.pdd.core.Utilities.getOpenspcoop2MessageFactory(this.logger.getLogger(),this.requestMsg, this.requestInfo, MessageRole.RESPONSE);
  229.             OpenSPCoop2MessageParseResult pr = messageFactory.createMessage(this.requestMsg.getMessageType(),MessageRole.RESPONSE,
  230.                     this.requestMsg.getContentType(),
  231.                     bin,notifierInputStreamParams,
  232.                     this.openspcoopProperties.getAttachmentsProcessingMode());
  233.             // Non funziona con gli attachments: this.responseMsg = OpenSPCoop2MessageFactory.getMessageFactory().createMessage(request.getRequestMessage().getVersioneSoap(),(bout.toByteArray()),notifierInputStreamParams);
  234.             if(pr.getParseException()!=null){
  235.                 this.getPddContext().addObject(org.openspcoop2.core.constants.Costanti.CONTENUTO_RISPOSTA_NON_RICONOSCIUTO_PARSE_EXCEPTION, pr.getParseException());
  236.             }
  237.             this.responseMsg = pr.getMessage_throwParseException();
  238.                        
  239.             // content length
  240.             if(this.responseMsg!=null){
  241.                 this.contentLength = messaggioArray.length;
  242.             }
  243.            
  244.         }catch(Exception e){
  245.             this.eccezioneProcessamento = e;
  246.             this.logger.error("Riscontrato errore durante l'echo del msg soap",e);
  247.             this.errore = "Riscontrato errore durante l'echo del msg soap:" +this.readExceptionMessageFromException(e);
  248.             return false;
  249.         }finally{
  250.             // release database
  251.             this.dbManager.releaseResource(this.openspcoopProperties.getIdentitaPortaDefault(this.getProtocolFactory().getProtocol(), this.requestInfo),"ConnettoreStresstest", this.resource);
  252.         }
  253.        
  254.         return true;
  255.     }
  256.    
  257.     /**
  258.      * Ritorna l'informazione su dove il connettore sta spedendo il messaggio
  259.      *
  260.      * @return location di inoltro del messaggio
  261.      */
  262.     @Override
  263.     public String getLocation() throws ConnettoreException {
  264.         return ConnettoreUtils.buildLocationWithURLBasedParameter(this.logger!=null ? this.logger.getLogger() : null, this.requestMsg, ConnettoreStresstest.ENDPOINT_TYPE, this.propertiesUrlBased, LOCATION,
  265.                 this.getProtocolFactory(), this.idModulo);
  266.     }
  267.  
  268.    
  269.    
  270.     private String buildProtocolHeader(ConnettoreMsg request) throws Exception{
  271.         Busta bustaRichiesta = request.getBusta();
  272.         if( CostantiLabel.SPCOOP_PROTOCOL_NAME.equals(bustaRichiesta.getProtocollo())){
  273.             return buildSPCoopProtocolHeader(request);
  274.         }
  275.         else{
  276.             return "";
  277.         }
  278.     }
  279.    

  280.    
  281.     private String buildSPCoopProtocolHeader(ConnettoreMsg request) throws Exception{  
  282.        
  283.         Busta bustaRichiesta = request.getBusta();
  284.        
  285.         StatefulMessage state = new StatefulMessage(null, this.logger.getLogger());
  286.        
  287.         Object id = this.getPddContext().getObject(Costanti.ID_TRANSAZIONE);
  288.         String idTransazione = null;
  289.         if(id!=null){
  290.             idTransazione = (String) id;
  291.         }
  292.                
  293.         StringBuilder protocolHeader = new StringBuilder();
  294.        
  295.         if(bustaRichiesta!=null && (bustaRichiesta.sizeListaEccezioni()==0) && !ConsegnaContenutiApplicativi.ID_MODULO.equals(request.getIdModulo())){
  296.             // Creo busta di risposta solo se la busta di richiesta non conteneva una busta SPCoop Errore e se il profilo lo richiede.
  297.                        
  298.             String idRiscontro = null;  
  299.            
  300.             IProtocolFactory<?> protocolFactory = ProtocolFactoryManager.getInstance().getProtocolFactoryByName(bustaRichiesta.getProtocollo());
  301.             ITraduttore traduttore = protocolFactory.createTraduttore();
  302.            
  303.             protocolHeader.append("<eGov_IT:Intestazione SOAP_ENV:actor=\"http://www.cnipa.it/eGov_it/portadominio\" SOAP_ENV:mustUnderstand=\"1\" " +
  304.                     "xmlns:SOAP_ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:eGov_IT=\"http://www.cnipa.it/schemas/2003/eGovIT/Busta1_0/\"><eGov_IT:IntestazioneMessaggio>");
  305.            
  306.             // mittente
  307.             protocolHeader.append("<eGov_IT:Mittente><eGov_IT:IdentificativoParte tipo=\""+traduttore.toProtocolOrganizationType(bustaRichiesta.getTipoDestinatario())+"\">"+bustaRichiesta.getDestinatario()+"</eGov_IT:IdentificativoParte></eGov_IT:Mittente>");
  308.        
  309.             // destinatario
  310.             protocolHeader.append("<eGov_IT:Destinatario><eGov_IT:IdentificativoParte tipo=\""+traduttore.toProtocolOrganizationType(bustaRichiesta.getTipoMittente())+"\">"+bustaRichiesta.getMittente()+"</eGov_IT:IdentificativoParte></eGov_IT:Destinatario>");
  311.        
  312.             // ProfiloCollaborazione
  313.             if(bustaRichiesta.getProfiloDiCollaborazione()!=null){

  314.                
  315.                 if(org.openspcoop2.protocol.sdk.constants.ProfiloDiCollaborazione.ONEWAY.equals(bustaRichiesta.getProfiloDiCollaborazione()) &&
  316.                         bustaRichiesta.isConfermaRicezione() &&
  317.                         this.openspcoopProperties.isGestioneRiscontri(CostantiRegistroServizi.IMPLEMENTAZIONE_STANDARD)){
  318.                    
  319.                         protocolHeader.append("<eGov_IT:ProfiloCollaborazione>"+traduttore.toString(bustaRichiesta.getProfiloDiCollaborazione())+"</eGov_IT:ProfiloCollaborazione>");
  320.                         // Attendono riscontro
  321.                         idRiscontro = bustaRichiesta.getID();
  322.                 } else if(org.openspcoop2.protocol.sdk.constants.ProfiloDiCollaborazione.ASINCRONO_ASIMMETRICO.equals(bustaRichiesta.getProfiloDiCollaborazione()) &&
  323.                         bustaRichiesta.getRiferimentoMessaggio()==null){
  324.                    
  325.                         // devo generare ricevuta
  326.                         protocolHeader.append("<eGov_IT:ProfiloCollaborazione tipo=\""+traduttore.toProtocolServiceType(bustaRichiesta.getTipoServizio())+"\" servizioCorrelato=\""+
  327.                                 (bustaRichiesta.getServizio()+"Correlato")+"\" >"+traduttore.toString(bustaRichiesta.getProfiloDiCollaborazione())+"</eGov_IT:ProfiloCollaborazione>");
  328.                 } else if(org.openspcoop2.protocol.sdk.constants.ProfiloDiCollaborazione.ASINCRONO_SIMMETRICO.equals(bustaRichiesta.getProfiloDiCollaborazione()) &&
  329.                         bustaRichiesta.getRiferimentoMessaggio()==null){
  330.                
  331.                     // salvo messaggio sul database asincrono/repositoryEGov
  332.                     // get database
  333.                     try{
  334.                         this.resource = this.dbManager.getResource(this.openspcoopProperties.getIdentitaPortaDefault(this.getProtocolFactory().getProtocol(), this.requestInfo),"ConnettoreStresstest",idTransazione);
  335.                     }catch(Exception e){
  336.                         throw new Exception("Risorsa non ottenibile",e);
  337.                     }
  338.                     if(this.resource==null)
  339.                         throw new Exception("Risorsa is null");
  340.                     if(this.resource.getResource() == null)
  341.                         throw new Exception("Connessione is null");
  342.                     Connection connectionDB = (Connection) this.resource.getResource();
  343.                     //POOL,TRANSACTIONISOLATION:connectionDB.setTransactionIsolation(DBManager.getTransactionIsolationLevel());
  344.                    
  345.                     state.setConnectionDB(connectionDB);
  346.                    
  347.                     // repository
  348.                     RepositoryBuste repositoryBuste = new RepositoryBuste(state, true,this.getProtocolFactory());
  349.                     repositoryBuste.registraBustaIntoInBox(bustaRichiesta, new ArrayList<>() ,
  350.                             OpenSPCoop2Properties.getInstance().getRepositoryIntervalloScadenzaMessaggi());
  351.                     Integrazione infoIntegrazione = new Integrazione();
  352.                     infoIntegrazione.setIdModuloInAttesa(null);
  353.                     repositoryBuste.aggiornaInfoIntegrazioneIntoInBox(bustaRichiesta.getID(),infoIntegrazione);
  354.                
  355.                     // asincrono
  356.                     ProfiloDiCollaborazione profiloCollaborazione = new ProfiloDiCollaborazione(state,this.getProtocolFactory());
  357.                     profiloCollaborazione.asincronoSimmetrico_registraRichiestaRicevuta(bustaRichiesta.getID(),bustaRichiesta.getCollaborazione(),
  358.                             bustaRichiesta.getTipoServizioCorrelato(),bustaRichiesta.getServizioCorrelato(),bustaRichiesta.getVersioneServizioCorrelato(),true,
  359.                             this.openspcoopProperties.getRepositoryIntervalloScadenzaMessaggi());
  360.                
  361.                     // commit
  362.                     try{
  363.                         connectionDB.setAutoCommit(false);
  364.                         state.executePreparedStatement();
  365.            
  366.                         connectionDB.commit();
  367.                         connectionDB.setAutoCommit(true);
  368.                     }catch (Exception e) {  
  369.                         this.logger.error("Riscontrato errore durante la gestione transazione del DB per la richiesta: "+e.getMessage(),e);
  370.                         // Rollback quanto effettuato (se l'errore e' avvenuto sul commit, o prima nell'execute delle PreparedStatement)
  371.                         try{
  372.                             connectionDB.rollback();
  373.                         }catch(Exception er){
  374.                             // ignore
  375.                         }
  376.                         state.closePreparedStatement(); // Chiude le PreparedStatement aperte(e non eseguite) per il save del Msg
  377.                     }finally {
  378.                         // Ripristino connessione
  379.                         try{
  380.                             connectionDB.setAutoCommit(true);
  381.                         }catch(Exception er){
  382.                             // ignore
  383.                         }
  384.                     }
  385.                     protocolHeader.append("<eGov_IT:ProfiloCollaborazione>"+traduttore.toString(bustaRichiesta.getProfiloDiCollaborazione())+"</eGov_IT:ProfiloCollaborazione>");
  386.                 }
  387.                 else{
  388.                     protocolHeader.append("<eGov_IT:ProfiloCollaborazione>"+traduttore.toString(bustaRichiesta.getProfiloDiCollaborazione())+"</eGov_IT:ProfiloCollaborazione>");
  389.                 }
  390.             }
  391.            
  392.             // servizio
  393.             if(bustaRichiesta.getTipoServizio()!=null && bustaRichiesta.getServizio()!=null)
  394.                 protocolHeader.append("<eGov_IT:Servizio tipo=\""+traduttore.toProtocolServiceType(bustaRichiesta.getTipoServizio())+"\">"+bustaRichiesta.getServizio()+"</eGov_IT:Servizio>");
  395.            
  396.             // azione
  397.             if(bustaRichiesta.getAzione()!=null)
  398.                 protocolHeader.append("<eGov_IT:Azione>"+bustaRichiesta.getAzione()+"</eGov_IT:Azione>");
  399.            
  400.             // Messaggio
  401.             protocolHeader.append("<eGov_IT:Messaggio>");
  402.            
  403.             // Identificativo egov
  404.             String dominio = null;
  405.             if(request.getConnectorProperties()!=null)
  406.                 dominio = request.getConnectorProperties().get("identificativo-porta");
  407.             if(dominio==null)
  408.                 dominio=bustaRichiesta.getDestinatario()+"SPCoopIT";
  409.             String idBustaRisposta = null;
  410.             Imbustamento imbustatore = new Imbustamento(this.logger.getLogger(), this.getProtocolFactory(),state);
  411.             try{
  412.                 idBustaRisposta =
  413.                     imbustatore.buildID(new IDSoggetto(bustaRichiesta.getTipoDestinatario(), bustaRichiesta.getDestinatario(), dominio),
  414.                             null,
  415.                             this.openspcoopProperties.getGestioneSerializableDBAttesaAttiva(),
  416.                             this.openspcoopProperties.getGestioneSerializableDBCheckInterval(),
  417.                             RuoloMessaggio.RISPOSTA);
  418.             }catch(Exception e){
  419.                 // rilancio
  420.                 throw e;
  421.             }
  422.             protocolHeader.append("<eGov_IT:Identificatore>"+idBustaRisposta+"</eGov_IT:Identificatore>");
  423.        
  424.             // OraRegistrazione
  425.             String oraS = traduttore.getDate_protocolFormat(bustaRichiesta.getOraRegistrazione());
  426.             protocolHeader.append("<eGov_IT:OraRegistrazione tempo=\""+traduttore.toString(bustaRichiesta.getTipoOraRegistrazione())+"\">"+
  427.                     oraS+"</eGov_IT:OraRegistrazione>");
  428.            
  429.             // RiferimentoMessaggio
  430.             protocolHeader.append("<eGov_IT:RiferimentoMessaggio>"+bustaRichiesta.getID()+"</eGov_IT:RiferimentoMessaggio>");
  431.            
  432.             protocolHeader.append("</eGov_IT:Messaggio>");
  433.        
  434.             protocolHeader.append("</eGov_IT:IntestazioneMessaggio>");
  435.            
  436.             if(idRiscontro!=null){
  437.                
  438.                 protocolHeader.append("<eGov_IT:ListaRiscontri><eGov_IT:Riscontro>" +
  439.                         "<eGov_IT:Identificatore>"+idRiscontro+"</eGov_IT:Identificatore>" +
  440.                         "<eGov_IT:OraRegistrazione tempo=\""+traduttore.toString(bustaRichiesta.getTipoOraRegistrazione())+"\">"+oraS+"</eGov_IT:OraRegistrazione>" +
  441.                                 "</eGov_IT:Riscontro> </eGov_IT:ListaRiscontri>");
  442.             }
  443.            
  444.             protocolHeader.append("</eGov_IT:Intestazione>");
  445.            
  446.         }
  447.        
  448.         return protocolHeader.toString();
  449.     }
  450.    
  451. }