Convert Request SOAP to String

  Per convertire una request XML in String usiamo il marshal di JAXB:

  public void printXml(Object obj) {
try {
StringWriter sb = new StringWriter();
JAXBContext ctx = JAXBContext.newInstance(obj.getClass());
Marshaller marshaller = ctx.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
marshaller.marshal(obj, sb);
log.info(sb.toString());
}
catch (Exception e) {
e.printStackTrace();

// catch exception
}
catch (Throwable e) {
e.printStackTrace();

// catch exception
}
}

Nella request SOAP che si vuole stampare, aggiungere il tag:
@XmlRootElement
dove viene definita la classe

@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Contact", propOrder = {
"codecontactid",
})
public class Contact......................