|
|
@@ -14,12 +14,16 @@ import java.io.ByteArrayInputStream;
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
+import java.io.StringWriter;
|
|
|
+
|
|
|
import javax.xml.bind.JAXBContext;
|
|
|
+import javax.xml.bind.JAXBElement;
|
|
|
import javax.xml.bind.JAXBException;
|
|
|
import javax.xml.bind.Marshaller;
|
|
|
import javax.xml.bind.Unmarshaller;
|
|
|
import javax.xml.bind.ValidationEvent;
|
|
|
import javax.xml.bind.ValidationEventHandler;
|
|
|
+
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
import org.eclipse.risev2g.shared.v2gMessages.appProtocol.SupportedAppProtocolReq;
|
|
|
@@ -68,6 +72,24 @@ public abstract class ExiCodec {
|
|
|
setInStream(new ByteArrayInputStream(baos.toByteArray()));
|
|
|
baos.close();
|
|
|
|
|
|
+ // For debugging purposes, you can view the XML representation of marshalled messages
|
|
|
+ StringWriter sw = new StringWriter();
|
|
|
+ String className = "";
|
|
|
+
|
|
|
+ if (jaxbObject instanceof V2GMessage) {
|
|
|
+ className = ((V2GMessage) jaxbObject).getBody().getBodyElement().getName().getLocalPart();
|
|
|
+ } else if (jaxbObject instanceof SupportedAppProtocolReq) {
|
|
|
+ className = "SupportedAppProtocolReq";
|
|
|
+ } else if (jaxbObject instanceof SupportedAppProtocolRes) {
|
|
|
+ className = "SupportedAppProtocolRes";
|
|
|
+ } else {
|
|
|
+ className = "marshalled JAXBElement";
|
|
|
+ }
|
|
|
+
|
|
|
+ getMarshaller().marshal(jaxbObject, sw);
|
|
|
+ getLogger().debug("XML representation of " + className + ":\n" + sw.toString());
|
|
|
+ sw.close();
|
|
|
+
|
|
|
return getInStream();
|
|
|
} catch (JAXBException | IOException e) {
|
|
|
getLogger().error(e.getClass().getSimpleName() + " occurred while trying to marshal to InputStream from JAXBElement", e);
|