使用阿里云Java SDK

本文为您介绍如何安装及调用阿里云Java SDK。

安装阿里云Java SDK

您可以通过下载阿里云Java SDK或添加Maven依赖的方式安装阿里云Java SDK:

  • 下载Java SDK

  • 如果您使用Apache Maven来管理Java项目,只需在项目的pom.xml文件添加如下依赖项:

<dependency>
   <groupId>com.aliyun</groupId>
   <artifactId>et_industry_openapi20210105</artifactId>
   <version>3.1.0</version>
</dependency>

调用示例

package test.com.aliyun.et_industry_openapi20210105;

import java.util.UUID;

import com.aliyun.et_industry_openapi20210105.Client;
import com.aliyun.et_industry_openapi20210105.models.OpenApiInvokeRequest;
import com.aliyun.et_industry_openapi20210105.models.OpenApiInvokeResponse;
import com.aliyun.teaopenapi.models.Config;
import com.google.gson.Gson;
import org.junit.Test;

/**
 * Client Tester.
 *
 @author <Authors name>
 * @version 1.0
 * @since <pre>1月 6, 2021</pre>
 */
public class ClientTest {

 public static void main(String[] args) throws Exception {
  Config config = new Config();
  config.setAccessKeyId("your accessKeyId");
  config.setAccessKeySecret("your accessKeySecret");
  config.setEndpoint("et-industry.cn-hangzhou.aliyuncs.com");

  Client client = new Client(config);
  OpenApiInvokeRequest request = new OpenApiInvokeRequest();
  request.setServiceId("dsfs345stert45");
        //节点id,节点调用必传。
  request.setNodeId("1");
  request.setType("EXPERIMENT");
  request.setParams("{\"in1\":{\"value\",1}}");
  //任务id需保证全局唯一
  request.setJobId("dasdsfdf");
  OpenApiInvokeResponse openApiInvokeResponse = client.openApiInvoke(request);
  Gson gson = new Gson();
  System.out.println(gson.toJSON(openApiInvokeResponse.getBody()));
 }

}