cxf 动态调用.

时间:2021-11-26 08:23:04

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;

import com.alibaba.fastjson.JSON;
import com.wistron.swpc.wiproxy.service.model.NodeGateway;
import com.wistron.swpc.wiproxy.service.util.PropertiesUtil;
import com.wistron.swpc.wiproxy.service.webservice.DataManager;
import com.wistron.wh.swpc.homesecurity.webservice.WiHGIWebService;
import org.apache.cxf.endpoint.Client;

private static Log log = LogFactory.getLog(DataManagerImpl.class);
 private static JaxWsDynamicClientFactory svr;
 private static Client client;
 private static String url;
 private static WiHGIWebService wws;
 
 static {
  log.debug("init..");
  //url = PropertiesUtil.remoteService;
  svr = JaxWsDynamicClientFactory.newInstance();
        client = svr.createClient("http://192.168.5.105:8080/HomeSecurity/service/HGIService?wsdl");
 }

@Override
 public void commandResult(NodeGateway ng) throws Exception {
  log.debug(url);
  
  //String content = JSON.toJSONString(ng);
  //log.debug(content);
  try {
   client.invoke("getCommandResult", ng.getIp(),ng.getMacStr(),ng.getRecvData(),ng.getRecvCount());
   //log.debug(wws.getCommandResult(content));
  } catch (Exception e) {
   log.error("Remote service can not connect");
   e.printStackTrace();
  }

}