|
|
@@ -16,29 +16,24 @@ import org.apache.http.util.EntityUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
-import javax.annotation.Resource;
|
|
|
import javax.xml.bind.DatatypeConverter;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.util.Date;
|
|
|
|
|
|
public class X5JsonHttpClient extends X5HttpClient {
|
|
|
|
|
|
- @Resource(name = "configuration")
|
|
|
- private Configuration configuration;
|
|
|
-
|
|
|
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
|
|
|
|
/**
|
|
|
* 构造器
|
|
|
*/
|
|
|
- public X5JsonHttpClient(String appId, String appKey, String url,BaseDao baseDao) {
|
|
|
+ public X5JsonHttpClient(String appId, String appKey, String url) {
|
|
|
this.appid = appId;
|
|
|
this.appkey = appKey;
|
|
|
this.url = url;
|
|
|
- this.baseDao = baseDao;
|
|
|
}
|
|
|
|
|
|
- public <T> X5Response<T> post(Object body, String type) {
|
|
|
+ public <T> X5Response<T> post(Object body, Configuration configuration, BaseDao baseDao, String type) {
|
|
|
String kind="";
|
|
|
if("ProductStock".equals(type)){
|
|
|
kind="物料库存同步";
|
|
|
@@ -49,7 +44,6 @@ public class X5JsonHttpClient extends X5HttpClient {
|
|
|
if (X5StringUtils.isEmpty(appid) || X5StringUtils.isEmpty(appkey) || X5StringUtils.isEmpty(url)) {
|
|
|
throw new X5Exception("1016", "The request at least contains appid appkey and url.");
|
|
|
}
|
|
|
- System.out.println("appid哈哈:"+appid+":"+appkey+":"+url);
|
|
|
String bodyString = null;
|
|
|
if (body instanceof String) {
|
|
|
bodyString = body.toString();
|
|
|
@@ -71,7 +65,7 @@ public class X5JsonHttpClient extends X5HttpClient {
|
|
|
String data = X5StringUtils.encodeBase64(JSON.toJSONString(x5Request));
|
|
|
System.out.println("4啊"+data);
|
|
|
String encoding = null;
|
|
|
- String account=configuration.getX5username()+":"+configuration.getX5username();
|
|
|
+ String account=configuration.getX5username()+":"+configuration.getX5password();
|
|
|
try {
|
|
|
encoding = DatatypeConverter.printBase64Binary(account.getBytes("UTF-8")); //username password 自行修改 中间":"不可少
|
|
|
} catch (UnsupportedEncodingException e) {
|