敏捷工具
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.8 KiB

2 years ago
  1. # Getting Started
  2. ### Reference Documentation
  3. For further reference, please consider the following sections:
  4. * [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)
  5. * [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.3.1.RELEASE/maven-plugin/reference/html/)
  6. * [Create an OCI image](https://docs.spring.io/spring-boot/docs/2.3.1.RELEASE/maven-plugin/reference/html/#build-image)
  7. //请求三方接口
  8. String bodys = requestObj.toJSONString();
  9. JSONObject resObj = new JSONObject();
  10. resObj.put("status","FAIL");
  11. try {
  12. /**
  13. * 重要提示如下:
  14. * HttpUtils请从
  15. * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java
  16. * 下载
  17. *
  18. * 相应的依赖请参照
  19. * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml
  20. */
  21. HttpResponse response = HttpUtils.doPost(host, path, "POST", headers, querys, bodys);
  22. int stat = response.getStatusLine().getStatusCode();
  23. if (stat != 200) {
  24. System.out.println("Http code: " + stat);
  25. System.out.println("http header error msg: " + response.getFirstHeader("X-Ca-Error-Message"));
  26. String bodyErr = EntityUtils.toString(response.getEntity());
  27. System.out.println("Http body error msg:" + bodyErr);
  28. resObj.put("errorMsg",bodyErr);
  29. }else{
  30. String res = EntityUtils.toString(response.getEntity());
  31. resObj.put("status","SUCCESS");
  32. resObj.putAll(JSON.parseObject(res));
  33. }
  34. } catch (Exception e) {
  35. resObj.put("status","FAIL");
  36. e.printStackTrace();
  37. } finally {
  38. if(!"SUCCESS".equals(resObj.getString("status"))){
  39. throw new StatusException(parseErr(resObj.getString("errorMsg")));
  40. }
  41. log.info("resObj={}",JSONObject.toJSONString(resObj,true));
  42. return resObj;
  43. }