운영하던 쇼핑몰을 종합쇼핑몰에 제휴하기 위한 API개발을 진행하기 위해 POSTMAN을 사용하게 되었습니다.

 

페이로드 란?

페이로드(payload)는 전송되는 데이터를 의미합니다. 데이터를 전송할 때, 헤더와 메타데이터, 에러 체크 비트 등과 같은 다양한 요소들을 함께 보내어, 데이터 전송의 효율과 안정성을 높히게 됩니다. 이 때, 보내고자 하는 데이터 자체를 의미하는 것이 바로 페이로드입니다. 우리가 택배 배송을 보내고 받을 때, 택배 물건이 페이로드이고, 송장이나 박스, 뾱뾱이와 같은 완충재 등등은 부가적인 것이기 때문에 페이로드가 아닙니다.

추가적으로 위키피디아에 아주 이해하기 좋은 예시가 아래와 같이 나와있어서 첨부합니다.

 

페이로드(payload)라는 단어는 운송업에서 비롯하였는데, 지급(pay)해야 하는 적화물(load)을 의미합니다. 예를 들어, 유조선 트럭이 20톤의 기름을 운반한다면 트럭의 총 무게는 차체, 운전자 등의 무게 때문에 그것보다 더 될 것이다. 이 모든 무게를 운송하는데 비용이 들지만, 고객은 오직 기름의 무게만을 지급(pay)하게 된다. 그래서 ‘pay-load’란 말이 나온 것이다

 

json으로 보는 실제 데이터에서의 payload는 아래의 json에서 “data”입니다. 그 이외의 데이터들은 전부 통신을 하는데 있어 용이하게 해주는 부차적인 정보들입니다.

 

더보기

{ 

    "status" : 

    "from": "localhost", 

    "to": "http://silverbell.com/sbell92/1", 

    "method": "GET", 

    "data":{ "message" : "There is a my Bang!" } 

}

 

REST란 말을 많이 들어봤을거 같아요. API 개발할때 요구사항이 RESTFUL하게 였으니, REST가 뭔지 알아봤습니다.

REST 란 ?

REST  “Representational State Transfer” 의 약자이다. 월드 와이드 웹과 같은 분산 하이퍼미디어 시스템을 위한 소프트웨어 아키텍처의 한 형식이다.

REST란, “웹에 존재하는 모든 자원(이미지, 동영상, DB 자원)에 고유한 URI를 부여해 활용하는 것으로, 자원을 정의하고 자원에 대한 주소를 지정하는 방법론을 의미한다고 한다.

이런 REST의 형식을 따른 시스템을 RESTful 이라고 부른다.

HTTP URI 를 통해 자원을 명시하고 HTTP Method를 통해 해당 자원의 대한 CRUD Operation을 적용한다.

 

CRUD Operation , HTTP Method

  1. Create : POST (자원 생성)
  2. Read : GET (자원의 정보 조회)
  3. Update : PUT (자원의 정보 업데이트)
  4. Delete : DELETE (자원 삭제)

 

REQUEST

POSTMAN으로 API의 데이터를 확인할때 2가지를 Request 했습니다. 

  • Request URL : [HTTP Method] URL
  • Request body : Request-payload

저 같은 경우는 개발서버, 운영서버 2가지의 Request URL을 사용했어야 했으므로

URL 부분을 전역변수로 사용했습니다.

 

[참고] POSTMAN 전역변수 사용방법

Environments 탭에 key-value 형식으로 mapping하여,

Send버튼을 눌러 Request를 요청하기전 toggle 버튼으로 url을 변경하였습니다.

 

 

Request를 보내고 Response를 받아오는 화면은 전체적으로 다음과 같습니다.

POSTMAN을 통해 Request하고 Response를 받아오는 화면

 

 

'spring > project' 카테고리의 다른 글

[DB] 테이블 생성하기  (0) 2018.05.21

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 10


알고리즘을 풀던중 라는 오류가 발생했습니다.


ArrayIndexOutOfBoundsException을 알아보도록 하겠습니다!!


우선 의미는

" 잘못된 인덱스를 사용해서 배열에 접근했다는 것을 알려주기 위한 예외입니다. 인덱스는 0보다 크거나 배열의 사이즈보다 작아야 합니다. "


라는 의미입니다.


저 같은 경우, for문을 통한 완전탐색을 하다가 마지막 인덱스에 크기를 잘못 고려하여 발생하였습니다.

(인덱스가 0~9 까지인데 10번째 인덱스 접근했습니다...ㅎㅎ)






* issue

SVN ....[get content / revert] failed....

  => 파일이 lock이 걸린것!!


goal)) clean up으로 lock을 풀어줘야한다.




* solution


1. lock을 풀기위해 sqlitebrowser라는 프로그램을 사용합니다.

 cf> https://sqlitebrowser.org/



2. 새 데이터베이스에 workspace > .svn > wc.db 를 추가합니다.

 ex> C:\[프로젝트 폴더]\workspace\webapps\l[프로젝트명]\.svn


3. select문으로 lock의 여부를 확인후 delete 문으로 실행!


cf> WORK_QUEUE와 WC_LOCK이 delete 되어야 한다. 

# select

*

from WORK_QUEUE;


--delete from WORK_QUEUE;


# select

*

from WC_LOCK;


--delete from WC_LOCK;

4. 우리의 목표였던 svn에서의 clean up을 실행한다.


Maven - 이클립스 Maven 연동 시 plug in 에러 날 경우


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Multiple annotations found at this line:
- Execution default-testResources of goal org.apache.maven.plugins:maven-resources- plugin:2.4.3:testResources failed: 
Plugin org.apache.maven.plugins:maven-resources-plugin:2.4.3 or one of its dependencies could not be resolved: Failed to collect 
dependencies for org.apache.maven.plugins:maven-resources-plugin:jar:2.4.3 () (org.apache.maven.plugins:maven-resources-
plugin:2.4.3:testResources:default-testResources:process-test-resources)
- Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile 
(execution: default-compile, phase: compile)
- CoreException: Could not get the value for parameter compilerId for plugin execution default-compile: 
PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.2 or one of its dependencies could not be 
resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2 (): 
ArtifactDescriptorException: Failed to read artifact descriptor for org.apache.maven:maven-plugin-api:jar:2.0.6
ArtifactResolutionException: Failure to transfer org.apache.maven:maven-plugin-api:pom:2.0.6 from http://repo1.maven.org/
maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or 
updates are forced. Original error: Could not transfer artifact org.apache.maven:maven-plugin-api:pom:2.0.6 from/to central (http://
repo1.maven.org/maven2): null to http://repo1.maven.org/maven2/org/apache/maven/maven-plugin-api/2.0.6/maven-plugin-
api-2.0.6.pom
- CoreException: Could not get the value for parameter compilerId for plugin execution default-testCompile: 
PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.2 or one of its dependencies could not be 
resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2 (): 
ArtifactDescriptorException: Failed to read artifact descriptor for org.apache.maven:maven-plugin-api:jar:2.0.6
ArtifactResolutionException: Failure to transfer org.apache.maven:maven-plugin-api:pom:2.0.6 from http://repo1.maven.org/
maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or 
updates are forced. Original error: Could not transfer artifact org.apache.maven:maven-plugin-api:pom:2.0.6 from/to central (http://
repo1.maven.org/maven2): null to http://repo1.maven.org/maven2/org/apache/maven/maven-plugin-api/2.0.6/maven-plugin-
api-2.0.6.pom
- Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.4.3:resources failed: Plugin 
org.apache.maven.plugins:maven-resources-plugin:2.4.3 or one of its dependencies could not be resolved: Failed to collect 
dependencies for org.apache.maven.plugins:maven-resources-plugin:jar:2.4.3 () (org.apache.maven.plugins:maven-resources-
plugin:2.4.3:resources:default-resources:process-resources)
- Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:
2.3.2:testCompile (execution: default-testCompile, phase: test-compile)
cs

대략 이런 에러가 발생했을 경우.

POM.xml을 확인해보면 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.lala.sarasa</groupId>
    <artifactId>msrdecision</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>msrdecision Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>hello</finalName>
    </build>
</project>
cs


이렇게 되어 있을 것이고,
해결방법은 POM.xml에

1
2
3
4
5
<dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.4.3</version>
</dependency>
cs

이런식으로 디펜던시를 추가해주면 된다.(현재 날짜 기준으로 최신버전인 3.2.1은 되지 
않는다.)


이렇게 작성해준 뒤에, 
1. 프로젝트 우클릭 > Run As > Maven Install
2. 이클립스 프로젝트 탐색기에서 해당 프로젝트 클릭 후 F5(새로고침)
3. 프로젝트 우클릭 > Maven > Update Project 


'spring > project' 카테고리의 다른 글

[API 개발] POST MAN 사용법 및 개념 (feat. REST, payload)  (0) 2021.02.15


[1 단계] Servers tab에 server.xml source보기 클릭.



[2 단계] path 부분 중복되지 않게 수정해주기.


docBase : Eclipse상의 프로젝트 이름
path : 해당 프로젝트가 웹 상에 노출될 경로




+ Recent posts