package com.weaver.seconddev.interfaces.oames;

import com.weaver.seconddev.interfaces.prop.ConfigProp;
import org.apache.axis2.kernel.http.HTTPConstants;
import org.apache.axis2.transport.http.HttpTransportProperties;
import  com.weaver.seconddev.interfaces.oames.SI_OA_HTOAApproFlowSync_OUTServiceStub.SendReq;
import  com.weaver.seconddev.interfaces.oames.SI_OA_HTOAApproFlowSync_OUTServiceStub.WLPS_SY_Request;
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 java.lang.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.weaver.verupgrade.general.BaseBean;
import com.weaver.verupgrade.general.Util;
import org.springframework.stereotype.Component;

@Component
public class ReturnMesWLPS_SYService extends BaseBean {
	@Autowired
	private ConfigProp configProp;
	private static final org.slf4j.Logger logger_d5127138 = LoggerFactory.getLogger(ReturnMesWLPS_SYService.class);

	public String[] returnRes(WLPS_SY_Request param) {
		String[] message = new String[2];
//		String url = (I18nContextUtilcus.getBean(Environment.class).getProperty("htmesoasync.A040WLPS")).trim();
		String url = configProp.getA040WLPS();
		try {
			logger_d5127138.error(String.valueOf("开始调用ReturnMesWLPS_SYService接口 param" + param.toString()));
			SI_OA_HTOAApproFlowSync_OUTServiceStub stub = new SI_OA_HTOAApproFlowSync_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);
//			HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
//			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());
			HttpTransportPropertiesImpl.Authenticator auth = new HttpTransportPropertiesImpl.Authenticator();
			auth.setUsername(configProp.getPo_user());
			auth.setPassword(configProp.getPo_password());
			stub._getServiceClient().getOptions().setProperty(org.apache.axis2.kernel.http.HTTPConstants.AUTHENTICATE,auth);
			SendReq sendReq = new SendReq();
			sendReq.setWLPS_SY_Req(param);
			stub.sI_OA_HTOAApproFlowSync_OUT(sendReq);
			message[0] = "S";
			message[1] = "";
			logger_d5127138.error(String.valueOf("调用ReturnMesWLPS_SYService接口结束"));
		} catch (Exception e) {
			message[0] = "E";
			message[1] = e.toString();
			logger_d5127138.error(String.valueOf("调用ReturnMesWLPS_SYService接口报错：" + message));
		}
		return message;
	}
}
