Ich muss XML-Nachricht protokollieren. Ich benutze diesen Code:Falsche Ausgabe mit Protokollobjekt zu XML
//From object to xml
public String createMarshalerDealInfoType(DealInfoType dealInfoType) {
StringWriter contactStr = null;
try {
JAXBContext jaxbContext = JAXBContext.newInstance(DealInfoType.class);
Marshaller jaxbUnmarshaller = jaxbContext.createMarshaller();
contactStr = new StringWriter();
jaxbUnmarshaller.marshal(dealInfoType, contactStr);
} catch (JAXBException e) {
log.error(e.getMessage());
}
return contactStr.toString();
}
In Testklasse:
ResponseType ResponseType = woNspDealWS.createRequestWS(DealRequestType);
String DealResponce = updateDealEsb.createMarshalerDealInfoType(ResponseType.getDealInfo());
log.debug("Response: \n " + DealResponce);
Problem: in Protokollausgabe ich nur die erste Zeile der Antwort-sehen, nicht ganze Nachricht
18:01:42,975 DEBUG updateDeal_Test:73 - Response: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
Wie kann ich make, um alle Antworten in XML zu drucken?
Gelöst: gelöst Problem mit Verwendung Annotation @ XmlRootElement für Testklasse.
Yeap, es ist richtig und nützlich. – Aleksawka