webservice提速调用远程接口 .

webservice提速调用远程接口 .
WebServiceStubHelper类:


public class WebServiceStubHelper
{
  
    private static URL imUrl;
   
    private final static String HTTP_PREFIX = "http://";
   
    //im服务地址配置
    private static String imServiceIP =
        Configuration.getInstance().getConfigValue("imServiceIP", Constant.EMPTY_STRING);
    private static String imServicePort =
        Configuration.getInstance().getConfigValue("imServicePort", Constant.EMPTY_STRING);
    private static String imServicePost =
        Configuration.getInstance().getConfigValue("imServicePost", Constant.EMPTY_STRING);
   
  
    /** The IM stub. */
   
    private SysMessageExSendSysMessageEx imStub = null;
   
    /** The instance. */
    private static WebServiceStubHelper instance = null;
    
    static
    {
        try
        {
            
            String imServiceURL =   HTTP_PREFIX+pgmServiceIP+":"+pgmServicePort

+"/"+imServicePost;
            imUrl = new URL(imServiceURL);
            
        }
        catch (MalformedURLException e)
        {
            DebugLogFactory.error(WebServiceStubHelper.class, "Error", e);
        }
    }
    
    private WebServiceStubHelper()
    {

  try//【此处提速调用远程接口】
        {
             EngineConfiguration defaultConfig =

EngineConfigurationFactoryFinder.newFactory().getClientEngineConfig();
           
            SimpleProvider config = new SimpleProvider(defaultConfig);
           
            config.deployTransport(HTTPTransport.DEFAULT_TRANSPORT_NAME, new

PortalCommonsHTTPSender());
            imStub = new GnsServiceLocator(config).getSysMessageExSendSysMessageEx(imUrl);
        }
        catch (ServiceException e)
        {
            DebugLogFactory.error(this.getClass(), "Get imStub failed", e);
        }
       
    }
   
   
    private static WebServiceStubHelper getInstance()
    {
        if (null == instance)
        {
            instance = new WebServiceStubHelper();
        }
        return instance;
    }
   
  
    public static SysMessageExSendSysMessageEx getImStub()
    {
        return getInstance().imStub;
    }
}

原文地址:https://www.cnblogs.com/qqzy168/p/3137008.html