package com.weaver.seconddev.interfaces.crmoa;

import com.weaver.seconddev.interfaces.prop.ConfigProp;
import com.weaver.seconddev.interfaces.crmoa.CRM_SyncTempUnfreezeStub.*;
import org.apache.axis2.transport.http.impl.httpclient4.HttpTransportPropertiesImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.slf4j.LoggerFactory;
import com.weaver.verupgrade.general.BaseBean;
import com.weaver.verupgrade.general.Util;
import org.springframework.stereotype.Component;

@Component
public class CRM_SyncTempUnfreeze extends BaseBean {

    @Autowired
    private  ConfigProp configProp;

    private static final org.slf4j.Logger logger_8493e3b4 = LoggerFactory.getLogger(CRM_SyncTempUnfreeze.class);

    public CRM_TEMPUNFREEZE_RETURN[] call(CRM_TEMPUNFREEZE_HEAD[] param) throws Exception {
//        String url = Util.null2String(I18nContextUtilcus.getBean(Environment.class).getProperty("htcrmoasync.TempUnfreeze")).trim();
        logger_8493e3b4.error(" param ---" + param);
        String url = configProp.getTempUnfreeze();
        //http://sappod.hengtong.com:50000/XISOAPAdapter/MessageServlet?senderParty=&senderService=BS_OA&receiverParty=&receiverService=&interface=SI_HTCRMBlistTempLifting_OUT&interfaceNamespace=http%3A%2F%2Fhengtong.com%2FOA%2FHTCRMBlistTempLifting
        //http://10.6.6.77:8070/CRM_SyncTempUnfreeze.asmx
        logger_8493e3b4.error(" url ---" + url);
        logger_8493e3b4.error(" configProp.getPo_user() ---" + configProp.getPo_user());
        logger_8493e3b4.error(" configProp.getPo_password() ---" + configProp.getPo_password());


        HttpTransportPropertiesImpl.Authenticator auth = new HttpTransportPropertiesImpl.Authenticator();
        auth.setUsername(configProp.getPo_user());
        auth.setPassword(configProp.getPo_password());



        CRM_SyncTempUnfreezeStub stub=new CRM_SyncTempUnfreezeStub(url);
        stub._getServiceClient().getOptions().setProperty("__CHUNKED__", Boolean.FALSE);
        stub._getServiceClient().getOptions().setProperty(org.apache.axis2.kernel.http.HTTPConstants.AUTHENTICATE,auth);

        CRM_SyncTempUnfreezeStub.CRM_OA_SyncTempUnfreezeList req = new CRM_SyncTempUnfreezeStub.CRM_OA_SyncTempUnfreezeList();
        CRM_SyncTempUnfreezeStub.ArrayOfCRM_TEMPUNFREEZE_HEAD arrayOfCRMTempunfreezeHead = new CRM_SyncTempUnfreezeStub.ArrayOfCRM_TEMPUNFREEZE_HEAD();
        arrayOfCRMTempunfreezeHead.setCRM_TEMPUNFREEZE_HEAD(param);
        req.setTempUnfreezeList(arrayOfCRMTempunfreezeHead);
        CRM_SyncTempUnfreezeStub.CRM_OA_SyncTempUnfreezeListResponse CRM_OA_SyncTempUnfreezeListResponse = stub.cRM_OA_SyncTempUnfreezeList(req);
        CRM_SyncTempUnfreezeStub.ArrayOfCRM_TEMPUNFREEZE_RETURN crmOaSyncTempUnfreezeListResult = CRM_OA_SyncTempUnfreezeListResponse.getCRM_OA_SyncTempUnfreezeListResult();
        CRM_SyncTempUnfreezeStub.CRM_TEMPUNFREEZE_RETURN[] crmTempunfreezeReturn = crmOaSyncTempUnfreezeListResult.getCRM_TEMPUNFREEZE_RETURN();
        return crmTempunfreezeReturn;


//        SI_HTCRMBlistTempLifting_OUTServiceStub stub = new SI_HTCRMBlistTempLifting_OUTServiceStub(url);
//        stub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
//        stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(300000);
//        HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
//
//        stub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth);
////        auth.setUsername(Util.null2String(I18nContextUtilcus.getBean(Environment.class).getProperty("htportaloaUrl.po_user")).trim());
////        auth.setPassword(Util.null2String(I18nContextUtilcus.getBean(Environment.class).getProperty("htportaloaUrl.po_password")).trim());
//        auth.setUsername(configProp.getPo_user());
//        auth.setPassword(configProp.getPo_password());
//
//        CRM_OA_SyncTempUnfreezeList req = new CRM_OA_SyncTempUnfreezeList();
//        ArrayOfCRM_TEMPUNFREEZE_HEAD array = new ArrayOfCRM_TEMPUNFREEZE_HEAD();
//        array.setCRM_TEMPUNFREEZE_HEAD(param);
//        req.setTempUnfreezeList(array);
//
//        CRM_OA_SyncTempUnfreezeListResponse res = stub.sI_HTCRMBlistTempLifting_OUT(req);
//        ArrayOfCRM_TEMPUNFREEZE_RETURN ret = res.getCRM_OA_SyncTempUnfreezeListResult();
//        CRM_TEMPUNFREEZE_RETURN[] data = ret.getCRM_TEMPUNFREEZE_RETURN();
//        return data;
    }
}
