You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
admin-client-temperature/src/main/java/com/rehome/mqttclienttemperature/task/AgencyTask.java

88 lines
3.5 KiB
Java

package com.rehome.mqttclienttemperature.task;
import cn.hutool.http.webservice.SoapClient;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.rehome.mqttclienttemperature.utils.WebServiceUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.*;
/***
* Webservice
*/
//@Component
public class AgencyTask {
private static final Logger log = LoggerFactory.getLogger(AgencyTask.class);
//每1分钟执行一次
11 months ago
//@Scheduled(cron="0 0/1 * * * ?")
protected void addRfqs(){
log.info("调用本地布署的Webservice时间{}",new Date());
try {
Gson gson = new Gson();
// String url = "http://127.0.0.1:8873/webservice/AgencyService?wsdl";
// String namespace = "http://webservice.mqttclienttemperature.rehome.com/";
// String method = "queryAgencyStatInfo";
// Map<String, String> paramsMap = new HashMap();
// paramsMap.put("user_id", "4783748PL898878");
// paramsMap.put("token", "37483748YU23");
// paramsMap.put("user_name", "371522");
//
// Map<String, String> paramBodyMap = new HashMap();
// paramBodyMap.put("paramBody", gson.toJson(paramsMap));
// String result = WebServiceUtils.invoke(url,namespace,method,paramBodyMap);
// log.info("结果:"+result);
String url = "http://127.0.0.1:8873/webservice/AgencyService?wsdl";
String namespace = "http://webservice.mqttclienttemperature.rehome.com/";
String method = "syncAgencyStatInfo";
Map<String, String> paramsMap = new HashMap();
paramsMap.put("user_id", "4783748PL898878");
paramsMap.put("token", "37483748YU23");
paramsMap.put("user_name", "371522");
Map<String, String> paramBodyMap = new HashMap();
paramBodyMap.put("paramBody", gson.toJson(paramsMap));
String result = WebServiceUtils.invoke(url,namespace,method,paramBodyMap);
log.info("结果:"+result);
// String url = "http://127.0.0.1:8873/ws/ApiCommonService?wsdl";
// String namespace = "http://webservice.mqttclienttemperature.rehome.com/";
// String method = "commonApi";
// Map<String, String> paramsMap = new HashMap();
// paramsMap.put("param1", "12");
// paramsMap.put("param2", "332");
//
// String result = WebServiceUtils.invoke(url,namespace,method,paramsMap);
// log.info("结果:"+result);
// SoapClient soapClient = SoapClient.create("http://127.0.0.1:8873/ws/ApiCommonService?wsdl");
// soapClient.setMethod("commonApi", "http://webservice.mqttclienttemperature.rehome.com/").setParam("param1", "1").setParam("param2","2");
// String send = soapClient.send(true);
// System.out.println(send);
// SoapClient soapClient = SoapClient.create(url);
// soapClient.setMethod(method, namespace).setParam("paramBody", gson.toJson(paramsMap));
// String send = soapClient.send(true);
// System.out.println(send);
} catch (Exception e) {
e.printStackTrace();
}
}
}