GestoreIntegrazionePDSoapWithRequestOut.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.integrazione;

  21. import javax.xml.soap.SOAPHeaderElement;

  22. import org.openspcoop2.message.OpenSPCoop2Message;
  23. import org.openspcoop2.message.OpenSPCoop2SoapMessage;
  24. import org.openspcoop2.message.constants.ServiceBinding;
  25. import org.openspcoop2.protocol.sdk.constants.TipoIntegrazione;

  26. /**
  27.  * Classe utilizzata per la ricezione di informazioni di integrazione
  28.  * dai servizi applicativi verso la porta di dominio.
  29.  *
  30.  * @author Poli Andrea (apoli@link.it)
  31.  * @author Lorenzo Nardi (nardi@link.it)
  32.  * @author $Author$
  33.  * @version $Rev$, $Date$
  34.  */
  35. public class GestoreIntegrazionePDSoapWithRequestOut extends GestoreIntegrazionePDSoap{

  36.    
  37.    
  38.     @Override
  39.     public void setOutRequestHeader(HeaderIntegrazione integrazione,
  40.             OutRequestPDMessage outRequestPDMessage) throws HeaderIntegrazioneException{
  41.    
  42.         try{
  43.             OpenSPCoop2Message msg = outRequestPDMessage.getMessage();
  44.             if(ServiceBinding.SOAP.equals(msg.getServiceBinding())==false){
  45.                 throw new Exception("Non utilizzabile con un Service Binding Rest");
  46.             }
  47.             OpenSPCoop2SoapMessage soapMsg = msg.castAsSoap();
  48.            
  49.             SOAPHeaderElement header = this.utilitiesRequest.buildHeader(integrazione,
  50.                     this.openspcoopProperties.getHeaderSoapNameIntegrazione(), // header name
  51.                     this.openspcoopProperties.getHeaderSoapPrefixIntegrazione(), // prefix
  52.                     this.openspcoopProperties.getHeaderSoapActorIntegrazione(), // namespace
  53.                     this.openspcoopProperties.getHeaderSoapActorIntegrazione(), // actor
  54.                     soapMsg,
  55.                     this.openspcoopProperties.getHeaderSoapExtProtocolInfoNomeElementoIntegrazione(), // nomeElemento ExtInfoProtocol
  56.                     this.openspcoopProperties.getHeaderSoapExtProtocolInfoNomeAttributoIntegrazione(), // nomeAttributo ExtInfoProtocol
  57.                     this.getProtocolFactory().createProtocolManager().buildIntegrationProperties(outRequestPDMessage.getBustaRichiesta(), true, TipoIntegrazione.SOAP)  
  58.                 );
  59.             //System.out.println((new org.openspcoop.dao.message.OpenSPCoopMessageFactory().createMessage().getAsString(header)));
  60.             if(soapMsg.getSOAPHeader() == null){
  61.                 soapMsg.getSOAPPart().getEnvelope().addHeader();
  62.             }
  63.             soapMsg.addHeaderElement(soapMsg.getSOAPHeader(), header);
  64.            
  65.         }catch(Exception e){
  66.             throw new HeaderIntegrazioneException("GestoreIntegrazionePDSoap, "+e.getMessage(),e);
  67.         }
  68.        
  69.     }
  70.    

  71. }