public void setFirstName(Vet obj, int index) { String firstName = "firstName_" + index; if (firstName.length() > 30) { firstName = firstName.substring(0, 30); } obj.setFirstName(firstName); }
public static void main(String args[]) throws JAXBException { ServiceRequest<Vet> serviceRequest = new ServiceRequest<Vet>(); serviceRequest.setChannelId("001"); serviceRequest.setRequestTime(new DateTime()); serviceRequest.addRequestParam("afdas", "asdfasd"); serviceRequest.addRequestParam("asdfasd", "afsd"); serviceRequest.addRequestParam("dasf", "safd"); Vet vets = new Vet(); vets.setFirstName("Farhan"); serviceRequest.setPayLoad(vets); // // ApplicationContext context = new // ClassPathXmlApplicationContext("applicationContext.xml"); // PetClinicManagerBase service = context.getBean(PetClinicManagerImpl.class); // Result<List<PetType>> owner = service.findAllPetTypes(); // main(). response.setResult(owner); JAXBContext jaxbContext = JAXBContext.newInstance(ServiceRequest.class); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(serviceRequest, System.out); }