GestoreIntegrazionePASoapWithResponseOut.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 spedizione di informazioni di integrazione
  28.  * dalla porta di dominio verso i servizi applicativi.
  29.  *
  30.  * @author Poli Andrea (apoli@link.it)
  31.  * @author $Author$
  32.  * @version $Rev$, $Date$
  33.  */
  34. public class GestoreIntegrazionePASoapWithResponseOut extends GestoreIntegrazionePASoap{

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