Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.latam.pax.cancloyred.ejb.clients;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.util.Properties;
- import javax.xml.ws.BindingProvider;
- import javax.xml.ws.Holder;
- import javax.xml.ws.WebServiceException;
- import javax.xml.ws.soap.SOAPFaultException;
- import com.latam.arq.commons.appconfig.properties.AppConfigException;
- import com.latam.arq.commons.appconfig.properties.AppConfigUtil;
- import com.latam.arq.commons.exceptions.LATAMException;
- import com.latam.pax.cancloyred.domain.CancelLoyaltyRedemptionRQDTO;
- import com.latam.pax.cancloyred.ejb.exceptions.CancelLoyaltyRedemptionException;
- import com.latam.pax.cancloyred.utils.Constants;
- import com.latam.pax.cancloyred.utils.LATAMPASSError;
- import com.siebel.customui.LOY37OCSLANQueryMemberLight;
- import com.siebel.customui.OCSLANQueryMemberLightInput;
- import com.siebel.customui.OCSLANQueryMemberLightOutput;
- import com.siebel.customui.OCSSpcQuerySpcMemberSpcLightSpcWF;
- import com.siebel.customui.SiebelFault;
- import com.siebel.webservices.SiebelSessionType;
- import com.siebel.xml.ocs_querymemberlight_input.ListOfLanInputQueryMemberLight;
- import com.siebel.xml.ocs_querymemberlight_input.LoyMember;
- import lombok.extern.slf4j.Slf4j;
- /**
- * Class customer service calls LOY37-OCSLANQueryMemberLight
- * @author
- *
- */
- @Slf4j
- public class WSQueryMemberLightClient {
- private String wsdl;
- private String endpoint;
- private String user;
- private String pass;
- private static LOY37OCSLANQueryMemberLight service;
- /**
- * INIT default values
- *
- * @param appConfig
- * @throws AppConfigException
- * @throws MalformedURLException
- */
- public WSQueryMemberLightClient(Properties appConfig){
- setEndpoint(appConfig.getProperty(Constants.QUERY_MEMBER_LIGHT_ENDPOINT));
- setWsdl(appConfig.getProperty(Constants.QUERY_MEMBER_LIGHT_WSDL));
- setUser(appConfig.getProperty(Constants.QUERY_MEMBER_LIGHT_USER));
- setPass(appConfig.getProperty(Constants.QUERY_MEMBER_LIGHT_PASS));
- }
- /**
- * method for completing the quest to send the Loyalty service
- *
- * @param input
- */
- private void completeRequestObject(OCSLANQueryMemberLightInput input, CancelLoyaltyRedemptionRQDTO businessData) {
- LoyMember loyaltymember = new LoyMember();
- loyaltymember.setMemberNumber(businessData.getLoyaltyMember().getFfNumber());
- /**
- * Al realizar la consulta al servicio de la cartola light, el programa (aunque se desconozca) debe ser '*'
- */
- loyaltymember.setProgramName("*");
- input.setListOfLanInputQueryMemberLight(new ListOfLanInputQueryMemberLight());
- input.getListOfLanInputQueryMemberLight().getLoyMember().add(loyaltymember);
- input.setPageSize("1");
- input.setStartRowNum("0");
- }
- /**
- * method to deliver the service Loyalty Service
- *
- * @param wsdl
- * @return
- * @throws WebServiceException
- */
- private static LOY37OCSLANQueryMemberLight getService(String wsdl)
- throws WebServiceException{
- if (service == null) {
- URL url;
- try {
- url = AppConfigUtil.getResourceFromAppConfig(wsdl).toURI().toURL();
- service = new LOY37OCSLANQueryMemberLight(url);
- } catch (MalformedURLException e) {
- logger.error("Excecption in MalformedURLException", e);
- } catch (AppConfigException e) {
- logger.error("Excecption in AppConfigException", e);
- }
- }
- return service;
- }
- /**
- * method to call the service SIEBEL Display Loyalty Transactions
- *
- * @param businessData
- * @return
- * @throws LATAMException
- * @throws SiebelFault
- */
- public OCSLANQueryMemberLightOutput execute(CancelLoyaltyRedemptionRQDTO businessData,Holder<String> securityHolder) throws CancelLoyaltyRedemptionException{
- OCSSpcQuerySpcMemberSpcLightSpcWF port = getService(this.wsdl).getOCSSpcQuerySpcMemberSpcLightSpcWF();
- ((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpoint);
- OCSLANQueryMemberLightInput input = new OCSLANQueryMemberLightInput();
- completeRequestObject(input, businessData);
- OCSLANQueryMemberLightOutput response = null;
- try{
- response = port.ocslanQueryMemberLight(this.user, this.pass, SiebelSessionType.NONE, securityHolder, input);
- }
- catch (SOAPFaultException ex){
- logger.error(ex.getMessage(),ex);
- throw new CancelLoyaltyRedemptionException(Constants.LATAM_LOY37_QUERY_MEMBER_LIGHT_ID, Constants.LATAM_LOY37_QUERY_MEMBER_LIGHT, ex.getMessage());
- }catch (WebServiceException e) {
- logger.error(e.getMessage(),e);
- throw new CancelLoyaltyRedemptionException(Constants.LATAM_LOY37_QUERY_MEMBER_LIGHT_ID, Constants.LATAM_LOY37_QUERY_MEMBER_LIGHT, e.getMessage());
- }
- catch (SiebelFault ex){
- logger.error(ex.getMessage(),ex);
- LATAMPASSError error = new LATAMPASSError();
- throw error.getException(ex);
- }
- return response;
- }
- public void setWsdl(String wsdl) {
- this.wsdl = wsdl;
- }
- public void setEndpoint(String endpoint) {
- this.endpoint = endpoint;
- }
- public void setUser(String user) {
- this.user = user;
- }
- public void setPass(String pass) {
- this.pass = pass;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement