List of usage examples for org.springframework.oxm.jaxb Jaxb2Marshaller setClassesToBeBound
public void setClassesToBeBound(@Nullable Class<?>... classesToBeBound)
From source file:frk.gpssimulator.GpsSimulatorApplication.java
@Bean public Jaxb2Marshaller getMarshaller() { Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller(); jaxb2Marshaller.setClassesToBeBound(Kml.class); final Map<String, Object> map = new HashMap<>(); map.put("jaxb.formatted.output", true); jaxb2Marshaller.setMarshallerProperties(map); return jaxb2Marshaller; }
From source file:demo.GpsSimulatorApplication.java
@Bean public Jaxb2Marshaller getMarshaller() { final Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller(); jaxb2Marshaller.setClassesToBeBound(Kml.class); final Map<String, Object> map = new HashMap<>(); map.put("jaxb.formatted.output", true); jaxb2Marshaller.setMarshallerProperties(map); return jaxb2Marshaller; }
From source file:com.cisco.cta.taxii.adapter.persistence.PersistenceConfiguration.java
@Bean public Jaxb2Marshaller taxiiStatusMarshaller() { Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller(); jaxb2Marshaller.setClassesToBeBound(TaxiiStatus.class); jaxb2Marshaller/* w w w.j a v a2 s . c o m*/ .setMarshallerProperties(ImmutableMap.of(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, true)); return jaxb2Marshaller; }
From source file:com.example.job.CustomerJobConfiguration.java
@Bean(name = "customerMarshaller") public Unmarshaller itemMarshaller() { Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); marshaller.setClassesToBeBound(Customer.class); return marshaller; }
From source file:com.work.petclinic.config.WebMvcConfig.java
@Bean(name = "marshallingXmlViewResolver") public ViewResolver getMarshallingXmlViewResolver() { Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); marshaller.setClassesToBeBound(new Class[] { Vets.class }); return new XmlViewResolver(marshaller); }
From source file:com.hp.autonomy.types.idol.marshalling.marshallers.jaxb2.QueueInfoResponseParser.java
QueueInfoResponseParser(final ResponseDataParser<QueueInfoGetStatusResponseData> responseDataMarshaller, final Map<String, Class<?>> expectedResults) { this.responseDataMarshaller = responseDataMarshaller; expectedResults.forEach((nodeName, clazz) -> { final Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); marshaller.setMappedClass(clazz); marshaller.setClassesToBeBound(clazz); this.expectedResults.put(nodeName, marshaller); });/* w ww. ja va 2s. co m*/ }
From source file:py.una.pol.karaku.test.test.services.KarakuFaultMessageResolverTest.java
@Test public void testResolvXteFault_NormalException() throws Exception { Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); marshaller.setClassesToBeBound(HTTPExceptionDTO.class); KarakuFaultMessageResolver resolver = new KarakuFaultMessageResolver(marshaller); // @formatter:off SOAPMessage message = getFromString( "" + "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"> " + " <SOAP-ENV:Header/> " + " <SOAP-ENV:Body> " + " <SOAP-ENV:Fault> " + " <faultcode>SOAP-ENV:Client</faultcode> " + " <faultstring xml:lang=\"en\">Invalid request</faultstring> " + " </SOAP-ENV:Fault>" + " </SOAP-ENV:Body>" + "</SOAP-ENV:Envelope>"); // @formatter:on SaajSoapMessage ssm = new SaajSoapMessage(message); try {// www .j a v a 2 s .c o m resolver.resolveFault(ssm); fail(); } catch (SoapFaultClientException exception) { assertEquals("Client", exception.getFaultCode().getLocalPart()); assertEquals("Invalid request", exception.getFaultStringOrReason()); } }
From source file:py.una.pol.karaku.test.test.services.KarakuFaultMessageResolverTest.java
/** * Test method for/*from ww w .java 2 s . com*/ * {@link py.una.pol.karaku.services.client.KarakuFaultMessageResolver#resolveFault(org.springframework.ws.WebServiceMessage)} * . */ @Test public void testResolveFault_HTTPException() throws Exception { Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); marshaller.setClassesToBeBound(HTTPExceptionDTO.class); KarakuFaultMessageResolver resolver = new KarakuFaultMessageResolver(marshaller); // @formatter:off SOAPMessage message = getFromString("" + "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"> " + " <SOAP-ENV:Header/> " + " <SOAP-ENV:Body> " + " <SOAP-ENV:Fault> " + " <faultcode>SOAP-ENV:Client</faultcode> " + " <faultstring xml:lang=\"en\">Invalid request</faultstring> " + " <detail> " + " <ns4:HTTPException xmlns:ns4=\"http://sigh.med.una.py/2013/schemas/base\"> " + " <code>1</code>" + " <summary>2</summary>" + " </ns4:HTTPException>" + " </detail>" + " </SOAP-ENV:Fault>" + " </SOAP-ENV:Body>" + "</SOAP-ENV:Envelope>"); // @formatter:on SaajSoapMessage ssm = new SaajSoapMessage(message); try { resolver.resolveFault(ssm); fail(); } catch (HTTPException exception) { assertEquals("1", exception.getCode()); assertEquals("2", exception.getShortDescription()); } }
From source file:py.una.pol.karaku.test.test.services.EndpointExceptionResolverTest.java
/** * Test method for//from ww w.j av a 2 s . c o m * {@link py.una.pol.karaku.services.server.EndpointExceptionResolver#customizeFault(java.lang.Object, java.lang.Exception, org.springframework.ws.soap.SoapFault)} * . * * @throws SecurityException * @throws NoSuchMethodException */ @Test public void testCustomizeFaultObjectExceptionSoapFault() throws Exception { Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); marshaller.setClassesToBeBound(HTTPExceptionDTO.class); EndpointExceptionResolver eer = new EndpointExceptionResolver(); eer.setMarshaller(marshaller); Method m = Endpoint.class.getMethod("call", String.class); MethodEndpoint me = new MethodEndpoint(new Endpoint(), m); Fault f = new Fault(); eer.customizeFault(me, new HTTPException("1", "code"), f); StringResult result = f.getFaultDetail().getResult(); // @formatter:off String expectedResult = "" + "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<ns2:HTTPException xmlns:ns2=\"http://sigh.med.una.py/2013/schemas/base\">" + "<code>1</code>" + "<summary>code</summary>" + "</ns2:HTTPException>"; // @formatter:on assertEquals(result.toString(), expectedResult); }
From source file:org.wallerlab.yoink.config.BatchConfig.java
/** * Standard Spring Batch item reader for JAXB * /*w w w. java 2 s. c o m*/ * @return JAXB reader bean -{@link org.springframework.oxm.jaxb.Jaxb2Marshaller} */ @Bean org.springframework.oxm.Unmarshaller unmarshaller() { Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); marshaller.setClassesToBeBound(Cml.class); return (Unmarshaller) marshaller; }