Advertisement
Guest User

Untitled

a guest
Aug 27th, 2015
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. protected String marshallerEx(Tickets tickets) throws JAXBException {
  2.  
  3. JAXBContext jaxbContext = JAXBContext.newInstance(Tickets.class);
  4. Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
  5.  
  6. jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
  7. StringWriter sw = new StringWriter();
  8.  
  9. // Marshal the tickets list in console
  10. jaxbMarshaller.marshal(tickets, sw);
  11.  
  12. LOGGER.info("marshal -> " + sw.toString());
  13.  
  14. return sw.toString();
  15. }
  16.  
  17. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  18. <tickets>
  19. <ticket>
  20. <assignedQueueId>61</assignedQueueId>
  21. <category>11</category>
  22. <cause>0</cause>
  23. <createDate>2015-08-19T13:34:18-04:00</createDate>
  24. <customFields/>
  25. </ticket>
  26. </tickets>
  27.  
  28. "<?xml version="1.0" encoding="UTF-8" standalone="yes"?>n<tickets>n <ticket>n <assignedQueueId>61</assignedQueueId>n <category>11</category>n <cause>0</cause>n <createDate>2015-08-19T13:34:18-04:00</createDate>n <customFields/>n </ticket>n</tickets>n"
  29.  
  30. HttpHeaders responseHeaders = new HttpHeaders();
  31. responseHeaders.set("content-type", "text/plain");
  32. return new ResponseEntity<String>(marshallerEx(tickets), responseHeaders, HttpStatus.OK);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement