JSON-RPC
JSON-RPC는 JSON으로 인코딩된 원격 프로시저 호출이다. 매우 간단한 프로토콜(XML-RPC와 매우 흡사함)로서, 소량의 데이터 타입과 명령들만을 정의하고 있다. JSON-RPC는 알림(notification, 서버로 데이터가 전송되고 응답을 요구하지 않음)을 허용하며, 다수의 호출이 서버로 전송되고 순서없이 응답되는 것을 허용한다.
사용
JSON-RPC는 이 프로토콜을 구현하는 서버로 요청을 보내는 것에 의해 동작한다. 이 때 클라이언트는 통상 리모트 시스템의 메소드 하나를 호출하려는 소프트웨어이다. 다수의 입력 파라미터가 배열 혹은 객체의 형태로 리모트 메소드로 전달될 수 있고, 메소드 자신은 다수의 출력 데이터를 마찬가지로 리턴할 수 있다. (구현 버전에 따라 다르다.)
하나의 리모트 메소드는 HTTP 혹은 TCP/IP 소켓 (버전 2.0으로 시작하는)을 사용해 리모트 서비스로 요청을 보내는 것에 의해 호출된다. HTTP를 사용할 때는 content-type이 application/json.[1]로 정의될 수도 있다.
모든 전송 타입은 JSON을 사용해 직렬화한 단일 객체이다.[2] 하나의 요청은 리모트 시스템에 의해 제공되는 특정한 메소드에 대한 호출이다. 이는 다음 3가지의 속성을 포함해야 한다:
method- 호출될 메소드의 이름 문자열.params- 정의된 메소드에 대한 파라미터로서 전달될 객체들의 배열.id- 임의 타입의 값. 이것은 요청에 대해 대응되는 응답을 매치시킨다.
요청의 수신자는 모든 수신된 요청에 대해 유효한 응답으로 답해야 한다. 응답은 아래에서 언급한 속성 들을 포함해야 한다.
result- 호출된 메소드에 의해 반환되는 데이터. 메소드 호출 중 에러가 발생했다면, 이 값은 null이어야 한다.error- 메소드 호출 중 에러가 있었으면, 특정한 에러 코드. 아니면null.id- 응답하는 요청의 id.
응답이 필요없거나 처음부터 요구되지도 않는 상황들이 있기 때문에, 알림(notification)이 도입되었다. 알림은 id가 없는 요청과 유사하다. 응답이 리턴되지 않을 것이기 때문에 id가 필요없는 것이다. 이 경우, id 속성은 생략(버전 2.0)되거나 null(버전 1.0)이어야 한다.
같이 보기
- 원격 프로시저 호출 (RPC)
- JSON
각주
- ↑ RFC 4627
- ↑ “specification - JSON-RPC - Trac”. 2008년 5월 17일에 원본 문서에서 보존된 문서. 2008년 5월 14일에 확인함.
외부 링크
- JSON-RPC
- 공식 웹사이트 - JSON-RPC Google Group 이 프로토콜에 관한 토론 주제들
- JSON-RPC specifications, links etc.
- Official JSON-RPC 1.0 homepage 보관됨 2014-12-29 - 웨이백 머신 (currently outdated)
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.