엔티티 작성
서버에 REST API POST 요청을 전송하여 엔티티를 작성하고 삽입할 수 있습니다.
이 태스크 정보
프로시저
결과
예
public void doPOSTUsingRESTRequest() throws Exception {
TestDriver driver = new TestDriver();
ConceptFactory cf = driver.getConceptFactory(ConceptFactory.class);
// Create a recipient entity in the hello_world solution
Recipient recp1 = cf.createRecipient("REP003");
recp1.setHelloCount(10000);
String solutionName = "hello_world";
String entityType = recp1.get$TypeName();
// com.ibm.ia.test.helloworld.Recipient
DriverProperties properties = new DriverProperties();
String runtimeHostName = properties.getproperty(
DriverProperties.RUNTIME_HOST_NAME, "localhost");
String url = "https://" + runtimeHostName
+ ":9443/ibm/ia/rest/solutions/" + solutionName
+ "/entity-types/" + entityType;
System.out.println(url);
HttpsURLConnection connection = getConnection(url, "POST", "application/xml");
driver.getModelSerializer().serializeEntity(DataFormat.GENERIC_XML,
connection.getOutputStream(), recp1, null);
connection.connect();
String content = getContent(connection, HttpURLConnection.HTTP_OK);
System.out.println(content);
connection.disconnect();
}