Example usage for org.springframework.oxm.jaxb Jaxb2Marshaller afterPropertiesSet

List of usage examples for org.springframework.oxm.jaxb Jaxb2Marshaller afterPropertiesSet

Introduction

In this page you can find the example usage for org.springframework.oxm.jaxb Jaxb2Marshaller afterPropertiesSet.

Prototype

@Override
    public void afterPropertiesSet() throws Exception 

Source Link

Usage

From source file:edu.wisc.my.portlets.feedback.dao.InfraWebServiceFeedbackSenderImpl.java

public void afterPropertiesSet() throws Exception {
    // initialize JAXB2
    Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
    marshaller.setContextPath("edu.wisc.kb.infra.ws");
    marshaller.afterPropertiesSet();
    webServiceTemplate.setMarshaller(marshaller);
    webServiceTemplate.setUnmarshaller(marshaller);

    // Tell webServiceTemplate to use CommonsHttpMessageSender
    CommonsHttpMessageSender messageSender = new CommonsHttpMessageSender();
    // allow 4 seconds for connect timeout
    messageSender.setConnectionTimeout(4000);
    // allow 20 seconds for infra web service to return
    messageSender.setReadTimeout(20000);
    webServiceTemplate.setMessageSender(messageSender);

    // create WSDL destination provider, override locationExpression to point to correct URI
    Wsdl11DestinationProvider provider = new Wsdl11DestinationProvider();
    provider.setWsdl(wsdlResource);//from w w w  .  ja v  a2  s  .  c  om
    webServiceTemplate.setDestinationProvider(provider);
    LOG.info("webServiceTemplate configuration complete; wsdl: " + wsdlResource.getURI().toString());
}

From source file:org.springsource.greenbeans.examples.edawithspring.etailer.common.MarshallingTests.java

private Marshaller jaxb2Marshaller() throws Exception {
    Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller();
    jaxb2Marshaller.setClassesToBeBound(PurchaseProcessingRequest.class, PurchaseLineItem.class);
    jaxb2Marshaller.setSchema(new ClassPathResource("/partner-schema.xsd"));
    jaxb2Marshaller.afterPropertiesSet();
    jaxb2Marshaller.setBeanClassLoader(Thread.currentThread().getContextClassLoader());
    return jaxb2Marshaller;
}

From source file:edu.unc.lib.dl.fedora.AccessClient.java

/**
 * Initializes this client bean, calling the initializers of dependencies.
 *
 * @throws Exception// w  w  w  .j a  va2  s .  com
 *            when initialization fails
 */
public void init() throws Exception {
    SaajSoapMessageFactory msgFactory = new SaajSoapMessageFactory();
    msgFactory.afterPropertiesSet();
    this.setMessageFactory(msgFactory);

    Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
    marshaller.setContextPath("edu.unc.lib.dl.fedora.types");
    marshaller.afterPropertiesSet();
    this.setMarshaller(marshaller);
    this.setUnmarshaller(marshaller);

    CommonsHttpMessageSender messageSender = new CommonsHttpMessageSender();
    UsernamePasswordCredentials creds = new UsernamePasswordCredentials(this.username, this.password);
    messageSender.setCredentials(creds);
    messageSender.afterPropertiesSet();
    this.setMessageSender(messageSender);

    // this.setFaultMessageResolver(new FedoraFaultMessageResolver());
    this.setDefaultUri(this.getFedoraContextUrl() + "/services/access");
    this.afterPropertiesSet();
}

From source file:edu.unc.lib.dl.fedora.ManagementClient.java

private void initializeConnections() throws Exception {
    SaajSoapMessageFactory msgFactory = new SaajSoapMessageFactory();
    msgFactory.afterPropertiesSet();/*from ww  w.  j  a v a 2 s .  c o  m*/
    this.setMessageFactory(msgFactory);

    Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
    marshaller.setContextPath("edu.unc.lib.dl.fedora.types");
    marshaller.afterPropertiesSet();
    this.setMarshaller(marshaller);
    this.setUnmarshaller(marshaller);

    CommonsHttpMessageSender messageSender = new CommonsHttpMessageSender();
    UsernamePasswordCredentials creds = new UsernamePasswordCredentials(this.getUsername(), this.getPassword());
    messageSender.setCredentials(creds);
    messageSender.setReadTimeout(300 * 1000);
    messageSender.afterPropertiesSet();
    this.setMessageSender(messageSender);

    // this.setFaultMessageResolver(new FedoraFaultMessageResolver());
    this.setDefaultUri(this.getFedoraContextUrl() + "/services/management");
    this.afterPropertiesSet();

    this.httpClient = HttpClientUtil.getAuthenticatedClient(this.getFedoraContextUrl(), this.getUsername(),
            this.getPassword(), this.httpManager);
}

From source file:org.springframework.batch.item.xml.Jaxb2NamespaceMarshallingTests.java

protected Marshaller getMarshaller() throws Exception {

    Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
    marshaller.setClassesToBeBound(new Class<?>[] { QualifiedTrade.class });
    marshaller.afterPropertiesSet();

    StringWriter string = new StringWriter();
    marshaller.marshal(new QualifiedTrade("FOO", 100, BigDecimal.valueOf(10.), "bar"),
            new StreamResult(string));
    String content = string.toString();
    assertTrue("Wrong content: " + content, content.contains("<customer>bar</customer>"));
    return marshaller;
}