Java Code Examples for org.springframework.web.client.RestTemplate.getRequestFactory()

The following are Jave code examples for showing how to use getRequestFactory() of the org.springframework.web.client.RestTemplate class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: openssp   File: JsonDataProviderConnector.java   Source Code and License Vote up 5 votes
private T connect(final PathBuilder config) throws RestClientException {
	final RestTemplate restTemplate = new RestTemplate(httpMessageConverters);
	final SimpleClientHttpRequestFactory rf = (SimpleClientHttpRequestFactory) restTemplate.getRequestFactory();
	rf.setReadTimeout(2000);
	rf.setConnectTimeout(2000);
	config.addParam("t", RestfulContext.getToken());
	final ResponseEntity<T> re = restTemplate.getForEntity(config.buildEndpointURI(), dtoType);
	return re.getBody();
}
 
Example 2
Project: openssp   File: LoginService.java   Source Code and License Vote up 5 votes
/**
 * Creates a login call to remote webservice.
 * 
 * @param config
 * @return token | RestClientException
 */
public static String loginDataProvider(final PathBuilder config) {
	final MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
	map.add("u", config.getMaster_user());
	map.add("p", config.getMaster_pw());
	final RestTemplate restTemplate = new RestTemplate();
	final SimpleClientHttpRequestFactory rf = (SimpleClientHttpRequestFactory) restTemplate.getRequestFactory();
	rf.setReadTimeout(3000);
	rf.setConnectTimeout(30000);
	try {
		final URI uri = new URIBuilder().setScheme("http").setCharset(StandardCharsets.UTF_8).setHost(config
				.getServer()).setPath("/ssp-data-provider/login/token").build();
		final TokenWrapper result = restTemplate.postForObject(uri, map, TokenWrapper.class);
		return result.getToken();
	} catch (final URISyntaxException | RestClientException e) {
		System.out.println("[WARNING] LoginService: " + e.getMessage());
	}

	return null;
}
 
Example 3
Project: pact-spring-mvc   File: TuPactRecordingServer.java   Source Code and License Vote up 5 votes
protected TuPactRecordingServer(RestTemplate restTemplate, File pactFile, ObjectStringConverter objectConverter, MediaType contentType) {
    this.restTemplate = restTemplate;
    this.pactFile = pactFile;
    this.objectConverter = objectConverter;
    originalRequestFactory = restTemplate.getRequestFactory();
    mockRestServiceServer = MockRestServiceServer.createServer(restTemplate);
    this.contentType = contentType;
}
 
Example 4
Project: apollo-custom   File: CtripMQService.java   Source Code and License Vote up 5 votes
@PostConstruct
public void init() {
  restTemplate = new RestTemplate();

  SimpleClientHttpRequestFactory rf = (SimpleClientHttpRequestFactory) restTemplate.getRequestFactory();
  rf.setReadTimeout(portalConfig.readTimeout());
  rf.setConnectTimeout(portalConfig.connectTimeout());

  MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
  converter.setSupportedMediaTypes(
      Arrays.asList(MediaType.APPLICATION_JSON, MediaType.APPLICATION_OCTET_STREAM));

  restTemplate.setMessageConverters(Arrays.asList(converter, new FormHttpMessageConverter()));

}
 
Example 5
Project: cf-java-client-sap   File: CloudControllerClientImpl.java   Source Code and License Vote up 4 votes
protected void configureCloudFoundryRequestFactory(RestTemplate restTemplate) {
    ClientHttpRequestFactory requestFactory = restTemplate.getRequestFactory();
    if (!(requestFactory instanceof CloudFoundryClientHttpRequestFactory)) {
        restTemplate.setRequestFactory(new CloudFoundryClientHttpRequestFactory(requestFactory));
    }
}