package com.ejie.ad74a.webservices.beneficiarioWS;

import javax.jws.HandlerChain;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;

import com.ejie.ad74a.ws.server.beneficiario.model.TipoComunicacionEnum;
import com.ejie.ad74a.ws.server.beneficiario.service.BeneficiarioProccesService;

@WebService(name = "BeneficiarioWebService", serviceName = "BeneficiarioWebService", targetNamespace = "http://com.ejie.ad74a.webservice")
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
@HandlerChain(file = "server-handlers.xml")

public class BeneficiarioWebServiceImpl extends SpringBeanAutowiringSupport implements BeneficiadioWebService {

	private static final Logger logger = LoggerFactory.getLogger(BeneficiarioWebServiceImpl.class);


	@Autowired
	private BeneficiarioProccesService beneficiarioProccesService;
	
    
	@Override
	public String esBeneficiario(@WebParam(name = "xmlRecibido", mode = WebParam.Mode.IN) String xmlRecibido) throws Exception {
		BeneficiarioWebServiceImpl.logger
				.debug("BeneficiarioWebServiceImpl - esBeneficiario: " + xmlRecibido);
//		Respuesta result = new Respuesta();
		String result = "";
		
		try {
			result = this.beneficiarioProccesService.proccesMessage(TipoComunicacionEnum.ES_BENEFICIARIO, xmlRecibido);
		} catch (Throwable e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return result;
	}
	
	@Override
	public String datosBeneficiario(@WebParam(name = "xmlRecibido", mode = WebParam.Mode.IN) String xmlRecibido) throws Exception {
		BeneficiarioWebServiceImpl.logger
				.debug("BeneficiarioWebServiceImpl - datosBeneficiario: " + xmlRecibido);
//		Respuesta result = new Respuesta();
		String result = "";
		
		try {
			result = this.beneficiarioProccesService.proccesMessage(TipoComunicacionEnum.DATOS_BENEFICIARIO, xmlRecibido);
		} catch (Throwable e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return result;
	}

}
