infection...
jersey client 를 이용한 rest api 호출 본문
pom.xml 에 jersy client 추가
maven install 후com.sun.jersey jersey-client ${jersey.version}
import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; Client client = Client.create(); MultivaluedMapqueryParams = new MultivaluedMapImpl(); queryParams.add("grant_type", "client_credentials"); WebResource webResource = client .resource("url"); ClientResponse response = null; response = webResource.queryParams(queryParams) .header("Content-Type", "application/json;charset=UTF-8") .get(ClientResponse.class); if (response.getStatus() != 200) { throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); } String output = response.getEntity(String.class); System.out.println(output);
'Develop > JAVA' 카테고리의 다른 글
Spring 실행 쿼리문 콘솔 출력 - log4jdbc-remix (feat. 메이븐) (0) | 2014.11.07 |
---|---|
[XMPP] Openfire 플러그인 개발하기 (0) | 2014.11.04 |