Example usage for org.springframework.http.converter.xml MarshallingHttpMessageConverter MarshallingHttpMessageConverter

List of usage examples for org.springframework.http.converter.xml MarshallingHttpMessageConverter MarshallingHttpMessageConverter

Introduction

In this page you can find the example usage for org.springframework.http.converter.xml MarshallingHttpMessageConverter MarshallingHttpMessageConverter.

Prototype

public MarshallingHttpMessageConverter(Marshaller marshaller) 

Source Link

Document

Construct a new MarshallingMessageConverter with the given Marshaller set.

Usage

From source file:edu.mayo.cts2.framework.core.client.Cts2RestClient.java

/**
 * Instantiates a new cts2 rest client./*from w  w  w. ja  va  2 s  .  c om*/
 *
 * @param marshaller the marshaller
 * @param trustSelfSignedSsl the trust self signed ssl
 */
public Cts2RestClient(Cts2Marshaller marshaller, boolean trustSelfSignedSsl) {
    this.marshaller = marshaller;
    this.converter = new MarshallingHttpMessageConverter(marshaller);

    if (trustSelfSignedSsl) {
        trustSelfSignedSSL();
    }
    this.nonSecureTemplate = this.createRestTemplate(null, null);
}

From source file:gov.nyc.doitt.gis.geoclient.service.configuration.WebConfig.java

@Bean
public HttpMessageConverter<?> xmlMessageConverter() {
    return new MarshallingHttpMessageConverter(this.marshaller);
}

From source file:com.neiljbrown.brighttalk.channels.reportingapi.client.spring.AppConfig.java

/**
 * Creates the list of {@link HttpMessageConverter} that the {@link RestTemplate} should use to read/write HTTP
 * request and response body. Ultimately dictates the set of media-types supported by the client.
 * <p>/*from  w  ww  . j a  v  a  2  s. c o m*/
 * A custom list of HTTP message converter are created rather than relying on the default ones provided by
 * RestTemplate to support the supply of a custom configured marshaller. The list of created HTTP message converter
 * will include a {@link MarshallingHttpMessageConverter} that uses the supplied {@link Marshaller}.
 * 
 * @return The created list of {@link HttpMessageConverter}.
 */
@Bean
public List<HttpMessageConverter<?>> httpMessageConverters() {
    return Arrays
            .asList(new HttpMessageConverter<?>[] { new MarshallingHttpMessageConverter(this.marshaller()) });
}

From source file:com.devnexus.ting.web.config.WebConfig.java

@Bean
public MarshallingHttpMessageConverter marshallingConverter() {
    MarshallingHttpMessageConverter converter = new MarshallingHttpMessageConverter(jaxbMarshaller);
    converter.setSupportedMediaTypes(Arrays.asList(MediaType.APPLICATION_XML));
    return converter;
}

From source file:com.hpe.elderberry.TaxiiConnection.java

public RestTemplate getRestTemplate() {
    if (restTemplate == null) {
        HttpClientBuilder builder = custom();

        if (useProxy) {
            if ("".equals(proxyHost)) {
                proxyHost = System.getProperty(discoveryUrl.getScheme() + ".proxyHost");
            }/*  w w  w.  ja  v  a  2  s  .  c  o m*/

            if (proxyPort == 0) {
                proxyPort = Integer.parseInt(System.getProperty(discoveryUrl.getScheme() + ".proxyPort", "0"));
            }

            if ("".equals(proxyHost) || proxyHost == null || proxyPort == 0) {
                log.warn("proxy requested, but not setup, not using a proxy");
            } else {
                log.info("using " + discoveryUrl.getScheme() + " proxy: " + proxyHost + ":" + proxyPort);
                HttpHost proxy = new HttpHost(proxyHost, proxyPort);
                DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);
                builder.setRoutePlanner(routePlanner);
            }
        }

        if (getTrustStore() != null || getKeyStore() != null) {
            SSLContext sslContext;
            try {
                sslContext = SSLContexts.custom()
                        .loadTrustMaterial(getTrustStore(), new TrustSelfSignedStrategy())
                        .loadKeyMaterial(getKeyStore(), keyPassword).build();
            } catch (Exception e) {
                log.error("unable to create SSL context, " + e.getMessage(), e);
                throw new RuntimeException(e);
            }
            SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext);
            builder.setSSLSocketFactory(sslsf);
        }

        if (!"".equals(username)) {
            restTemplate = new RestTemplate(
                    new PreemptiveAuthHttpRequestFactor(username, password, builder.build()));
        } else {
            restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactory(builder.build()));
        }

        if (marshaller == null) {
            marshaller = new Jaxb2Marshaller();
            marshaller.setPackagesToScan("org.mitre");
            try {
                marshaller.afterPropertiesSet();
            } catch (Exception e) {
                log.error("unable to create Jaxb2 Marshaller: " + e.getMessage(), e);
                throw new RuntimeException(e);
            }
        }

        MarshallingHttpMessageConverter converter = new MarshallingHttpMessageConverter(marshaller);
        converter.setSupportedMediaTypes(singletonList(APPLICATION_XML));
        //noinspection unchecked
        restTemplate.setMessageConverters(Collections.<HttpMessageConverter<?>>singletonList(converter));
    }

    return restTemplate;
}