List of usage examples for org.springframework.oxm.jaxb Jaxb2Marshaller setContextPath
public void setContextPath(@Nullable String contextPath)
From source file:org.cleverbus.common.Tools.java
/** * Unmarshals XML into object graph./* w ww . j a v a 2 s .c om*/ * * @param xml the input string * @param targetClass the target class * @return object graph * @see XmlConverter */ @SuppressWarnings("unchecked") public static <T> T unmarshalFromXml(String xml, Class<T> targetClass) { Jaxb2Marshaller jaxb2 = new Jaxb2Marshaller(); jaxb2.setContextPath(targetClass.getPackage().getName()); return (T) jaxb2.unmarshal(new StreamSource(new StringReader(xml))); }
From source file:org.cleverbus.common.Tools.java
/** * Marshals object graph into XML.//from w w w . j a va2s. c om * * @param obj the object graph * @param sourceClass the input class * @return XML as string * @see XmlConverter */ public static String marshalToXml(Object obj, Class sourceClass) { Jaxb2Marshaller jaxb2 = new Jaxb2Marshaller(); jaxb2.setContextPath(sourceClass.getPackage().getName()); StringWriter writer = new StringWriter(); StreamResult result = new StreamResult(writer); jaxb2.marshal(obj, result); return writer.toString(); }
From source file:org.openwms.core.app.ModuleConfiguration.java
public @Bean Unmarshaller unmarshaller() { Jaxb2Marshaller um = new Jaxb2Marshaller(); um.setContextPath("org.openwms.core.configuration.file"); return um;/*from w w w.ja v a 2s . com*/ }
From source file:org.beast.project.template.config.WebServiceConfig.java
@Bean public Jaxb2Marshaller payloadMarshaller() { Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); marshaller.setContextPath(ClassUtils.getPackageName(org.beast.project.template.model.ObjectFactory.class)); marshaller.setSchemas(schemaResources()); return marshaller; }
From source file:org.osgp.adapter.protocol.dlms.infra.ws.JasperWirelessConfigTest.java
@Bean public Jaxb2Marshaller jasperWirelessMarshaller() { final Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); marshaller.setContextPath("com.jasperwireless.api.ws.service"); return marshaller; }
From source file:io.getlime.push.configuration.PowerAuthWebServiceConfiguration.java
/** * Marshaller for PowerAuth SOAP service communication. * * @return JAXB marshaller with correctly configured context path. *///from ww w . j a va 2 s .c o m @Bean public Jaxb2Marshaller marshaller() { Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); marshaller.setContextPath("io.getlime.powerauth.soap"); return marshaller; }
From source file:dk.nsi.minlog.ws.config.WSConfig.java
@Bean(name = { "nspMarshaller", "nspUnmarshaller" }) public Jaxb2Marshaller nspMarshaller() { final Jaxb2Marshaller bean = new Jaxb2Marshaller(); bean.setContextPath("dk.nsi.minlog._2012._05._24"); return bean;//from w w w . j ava2 s. c o m }
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();//from ww w.j a va2 s .co m 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); webServiceTemplate.setDestinationProvider(provider); LOG.info("webServiceTemplate configuration complete; wsdl: " + wsdlResource.getURI().toString()); }
From source file:org.bremersee.common.web.client.ResponseErrorHandlerImpl.java
/** * Default constructor.//w ww . ja va2 s. c om */ public ResponseErrorHandlerImpl() { Jaxb2Marshaller m = new Jaxb2Marshaller(); m.setContextPath(ThrowableMessageDto.class.getPackage().getName()); unmarshaller = m; objectMapper = new ObjectMapper(); // see http://wiki.fasterxml.com/JacksonJAXBAnnotations AnnotationIntrospector primary = new JacksonAnnotationIntrospector(); AnnotationIntrospector secondary = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()); AnnotationIntrospectorPair pair = new AnnotationIntrospectorPair(primary, secondary); objectMapper.setAnnotationIntrospector(pair); }
From source file:org.bremersee.common.spring.autoconfigure.WebMvcExceptionResolver.java
public WebMvcExceptionResolver() { defaultExceptionMapper = new ThrowableToThrowableDtoMapper(); Jaxb2Marshaller m = new Jaxb2Marshaller(); m.setContextPath(ThrowableDto.class.getPackage().getName()); marshaller = m;/*from w w w. j av a 2s .c o m*/ objectMapper = new ObjectMapper(); // see http://wiki.fasterxml.com/JacksonJAXBAnnotations AnnotationIntrospector primary = new JacksonAnnotationIntrospector(); AnnotationIntrospector secondary = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()); AnnotationIntrospectorPair pair = new AnnotationIntrospectorPair(primary, secondary); objectMapper.setAnnotationIntrospector(pair); }