package com.weaver.seconddev.interfaces.easoa;

import com.weaver.seconddev.interfaces.prop.ConfigProp;
import org.apache.axis2.kernel.http.HTTPConstants;
import org.apache.axis2.transport.http.HttpTransportProperties;
import java.rmi.RemoteException;
import com.weaver.common.i18n.tool.util.I18nContextUtil;
import org.apache.axis2.transport.http.impl.httpclient4.HttpTransportPropertiesImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.weaver.verupgrade.file.Prop;
import com.weaver.verupgrade.general.Util;
import org.springframework.stereotype.Component;

@Component
public class CallTravelApplyService {

    private static final org.slf4j.Logger logger_ec0d40fa = LoggerFactory.getLogger(CallTravelApplyService.class);

    private SI_BusinessTripApplicationSync_OUTServiceStub.SyncTravelApplyService input = null;

    public void setInput(SI_BusinessTripApplicationSync_OUTServiceStub.SyncTravelApplyService resultIn) {
        this.input = resultIn;
    }

    @Autowired
    private ConfigProp configProp;  //注入

    public String[] call() throws RemoteException {
        String[] result = new String[5];
        // String url = "http://10.6.2.35:7001/easws/services/syncTravelApplyService?wsdl";
//        String url = Util.null2String(I18nContextUtilcus.getBean(Environment.class).getProperty("hteasoasync.TravelApply")).trim();
        String url =configProp.getTravelApply();
        // String url = "http://sappod.hengtong.com:50000/XISOAPAdapter/MessageServlet?senderParty=&senderService=BS_OA&receiverParty=&receiverService=&interface=SI_BusinessTripApplicationSync_OUT&interfaceNamespace=http://hengtong.com/OA/BusinessTripApplicationSync";
        SI_BusinessTripApplicationSync_OUTServiceStub stub = new SI_BusinessTripApplicationSync_OUTServiceStub(url);
        stub._getServiceClient().getOptions().setProperty("__CHUNKED__", Boolean.FALSE);
        stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(300000);
        stub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT,300000);
        stub._getServiceClient().getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT,300000);
        HttpTransportPropertiesImpl.Authenticator auth = new HttpTransportPropertiesImpl.Authenticator();
        auth.setUsername("pouser");
        auth.setPassword("654321");
        stub._getServiceClient().getOptions().setProperty(org.apache.axis2.kernel.http.HTTPConstants.AUTHENTICATE,auth);
        SI_BusinessTripApplicationSync_OUTServiceStub.SyncTravelApplyServiceResponse response = stub.sI_BusinessTripApplicationSync_OUT(input);
        SI_BusinessTripApplicationSync_OUTServiceStub.ResultInfo resultInfo = response.get_return();
        SI_BusinessTripApplicationSync_OUTServiceStub.SyncTravelApplyReturn[] Infos = resultInfo.getReturnInfos();
        result[0] = resultInfo.getISTAT();
        result[1] = resultInfo.getMESSAGE();
        result[2] = resultInfo.getITFID();
        result[3] = resultInfo.getSENDID();
        result[4] = resultInfo.getSYSID();
        return result;
    }
}
