|
# Getting Started
|
|
|
|
### Reference Documentation
|
|
For further reference, please consider the following sections:
|
|
|
|
* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)
|
|
* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.3.1.RELEASE/maven-plugin/reference/html/)
|
|
* [Create an OCI image](https://docs.spring.io/spring-boot/docs/2.3.1.RELEASE/maven-plugin/reference/html/#build-image)
|
|
|
|
|
|
//请求三方接口
|
|
String bodys = requestObj.toJSONString();
|
|
JSONObject resObj = new JSONObject();
|
|
resObj.put("status","FAIL");
|
|
try {
|
|
/**
|
|
* 重要提示如下:
|
|
* HttpUtils请从
|
|
* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java
|
|
* 下载
|
|
*
|
|
* 相应的依赖请参照
|
|
* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml
|
|
*/
|
|
HttpResponse response = HttpUtils.doPost(host, path, "POST", headers, querys, bodys);
|
|
int stat = response.getStatusLine().getStatusCode();
|
|
if (stat != 200) {
|
|
System.out.println("Http code: " + stat);
|
|
System.out.println("http header error msg: " + response.getFirstHeader("X-Ca-Error-Message"));
|
|
String bodyErr = EntityUtils.toString(response.getEntity());
|
|
System.out.println("Http body error msg:" + bodyErr);
|
|
resObj.put("errorMsg",bodyErr);
|
|
}else{
|
|
String res = EntityUtils.toString(response.getEntity());
|
|
resObj.put("status","SUCCESS");
|
|
resObj.putAll(JSON.parseObject(res));
|
|
}
|
|
} catch (Exception e) {
|
|
resObj.put("status","FAIL");
|
|
e.printStackTrace();
|
|
} finally {
|
|
if(!"SUCCESS".equals(resObj.getString("status"))){
|
|
throw new StatusException(parseErr(resObj.getString("errorMsg")));
|
|
}
|
|
log.info("resObj={}",JSONObject.toJSONString(resObj,true));
|
|
return resObj;
|
|
}
|