
/*
 * 
 */

package org.tempuri;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.Map;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceFeature;

import nc.bs.dao.BaseDAO;
import nc.bs.dao.DAOException;
import nc.bs.logging.Logger;
import nc.jdbc.framework.processor.MapListProcessor;
import nc.vo.pub.BusinessException;

/**
 * This class was generated by Apache CXF 2.2.4
 * Wed May 03 21:35:05 CST 2017
 * Generated source version: 2.2.4
 * 
 */


@WebServiceClient(name = "BGYMYUrgentPayWS", 
                  wsdlLocation = "http://202.104.28.239:8081/ERPMidService/BGYMYUrgentPayWS.asmx?wsdl",
                  targetNamespace = "http://tempuri.org/") 
public class BGYMYUrgentPayWS extends Service {

    public final static URL WSDL_LOCATION;
    public final static QName SERVICE = new QName("http://tempuri.org/", "BGYMYUrgentPayWS");
    public final static QName BGYMYUrgentPayWSSoap12 = new QName("http://tempuri.org/", "BGYMYUrgentPayWSSoap12");
    public final static QName BGYMYUrgentPayWSSoap = new QName("http://tempuri.org/", "BGYMYUrgentPayWSSoap");
    static {
//        URL url = null;
//        try {
//            url = new URL("http://202.104.28.239:8081/ERPMidService/BGYMYUrgentPayWS.asmx?wsdl");
//        } catch (MalformedURLException e) {
//            System.err.println("Can not initialize the default wsdl from http://202.104.28.239:8081/ERPMidService/BGYMYUrgentPayWS.asmx?wsdl");
//            // e.printStackTrace();
//        }
//        WSDL_LOCATION = url;
    	/**
    	 * 修改为读取动态地址动态地址
    	 */
    	  URL url = null;
    	  String mdpServerIP="";
      	try {
  			mdpServerIP=getGlobleSysInitValue("ORG030");
  			if(mdpServerIP==null || mdpServerIP.trim().length()==0){
  				Logger.error("成本核销IP不可为空");
  			}
  		} catch (BusinessException e1) {
  			Logger.error(e1.getMessage(),e1);
  		}
      	
          try {
          	url = new URL(mdpServerIP);
          } catch (MalformedURLException e) {
              System.err.println("Can not initialize the default wsdl from http://10.10.169.59:8534/uapws/service/com.yonyou.itf.mdm07.sharing.IMdSharingCenterService?wsdl");
              // e.printStackTrace();
          }
          WSDL_LOCATION = url;
    }

    public BGYMYUrgentPayWS(URL wsdlLocation) {
        super(wsdlLocation, SERVICE);
    }

    public BGYMYUrgentPayWS(URL wsdlLocation, QName serviceName) {
        super(wsdlLocation, serviceName);
    }

    public BGYMYUrgentPayWS() {
        super(WSDL_LOCATION, SERVICE);
    }

   
    
    /**
     * 
     * @return
     *     returns BGYMYUrgentPayWSSoap
     */
    @WebEndpoint(name = "BGYMYUrgentPayWSSoap12")
    public BGYMYUrgentPayWSSoap getBGYMYUrgentPayWSSoap12() {
        return super.getPort(BGYMYUrgentPayWSSoap12, BGYMYUrgentPayWSSoap.class);
    }

    /**
     * 
     * @param features
     *     A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy.  Supported features not in the <code>features</code> parameter will have their default values.
     * @return
     *     returns BGYMYUrgentPayWSSoap
     */
    @WebEndpoint(name = "BGYMYUrgentPayWSSoap12")
    public BGYMYUrgentPayWSSoap getBGYMYUrgentPayWSSoap12(WebServiceFeature... features) {
        return super.getPort(BGYMYUrgentPayWSSoap12, BGYMYUrgentPayWSSoap.class, features);
    }
    /**
     * 
     * @return
     *     returns BGYMYUrgentPayWSSoap
     */
    @WebEndpoint(name = "BGYMYUrgentPayWSSoap")
    public BGYMYUrgentPayWSSoap getBGYMYUrgentPayWSSoap() {
        return super.getPort(BGYMYUrgentPayWSSoap, BGYMYUrgentPayWSSoap.class);
    }

    /**
     * 
     * @param features
     *     A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy.  Supported features not in the <code>features</code> parameter will have their default values.
     * @return
     *     returns BGYMYUrgentPayWSSoap
     */
    @WebEndpoint(name = "BGYMYUrgentPayWSSoap")
    public BGYMYUrgentPayWSSoap getBGYMYUrgentPayWSSoap(WebServiceFeature... features) {
        return super.getPort(BGYMYUrgentPayWSSoap, BGYMYUrgentPayWSSoap.class, features);
    }
    
    public static String getGlobleSysInitValue(String initCode)
			throws BusinessException {

		String result = "";

		StringBuilder sql = new StringBuilder();
		sql.append("select value from pub_sysinit t ");
		sql.append(" where t.pk_org='GLOBLE00000000000000'");
		sql.append(" and t.initcode='" + initCode + "'");

		try {
			List list = (List) new BaseDAO().executeQuery(sql.toString(),
					new MapListProcessor());

			if (list != null) {
				Map map = null;
				if (list.get(0) != null) {
					map = (Map) list.get(0);
					result = map.get("value") == null ? "" : (String) map
							.get("value");
				}
			}
		} catch (DAOException e) {
			Logger.error(e.getMessage());
			throw new BusinessException(e.getMessage());
		}

		return result;
	}

}
