Sto utilizzando Castor per crearmi un flusso xml da un oggetto
il mio codice è:
try {
writer = new FileWriter("C:/file.xml");
Marshaller m = new Marshaller(writer);
Mapping myMapping = new Mapping();
myMapping.loadMapping("C:/mapping.xml");
m.setMapping(myMapping);
m.marshal(object);
writer.close();
} catch (Exception e) {
System.out.println("Exception: "+e.getMessage());
}
che mi crea un file xml sul disco
Successivamente devo mandare questo xml come stringa ad un servizio esterno, facendo così dovrò rileggermi il file e trasformarlo in string
Qualcuno può darmi un suggerimento, su come creare il file xml senza salvarlo su disco e poter mandare direttamente il flusso
Sono riuscito a stampare il flusso su console
Writer out3 = new BufferedWriter(new OutputStreamWriter(System.out));
try {
Marshaller m4 = new Marshaller(out3);
Mapping myMapping4 = new Mapping();
myMapping4.loadMapping("C:/mapping.xml");
m4.setMapping(myMapping4);
m4.marshal(object);
} catch (Exception e) {
System.out.println("Exception: "+e.getMessage());
}
Grazie

Rispondi quotando