Package org.springframework.web.client

Examples of org.springframework.web.client.RestTemplate.exchange()


        final HttpHeaders headers = new HttpHeaders();
        headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
        headers.setContentType((MediaType.APPLICATION_XML));
        final HttpEntity<Foo> entity = new HttpEntity<Foo>(resource, headers);

        final ResponseEntity<Foo> response = restTemplate.exchange(URI, HttpMethod.PUT, entity, Foo.class, resource.getId());
        final Foo fooResponse = response.getBody();

        Assert.assertEquals(resource.getId(), fooResponse.getId());
    }
View Full Code Here


      HttpEntity<String> request = new HttpEntity<String>( headers );

      String url = uri.build().toUriString();
      LOG.debug( "calling oauth2 token endpoint {}", url );

      ResponseEntity<Map> response = template.exchange( url, HttpMethod.GET, request, Map.class );
      body = response.getBody();

      if ( response.getStatusCode() != HttpStatus.OK ) {
        throw new RuntimeException(
            "Fetching OAuth2 token failed with status code: " + response.getStatusCode() );
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.