mardi 18 septembre 2018

Set SOAPElement attribute from reflected object - JAVA

i'm trying to set an attribute value from a Object in a SOAPElement.

Field[] fields = object.getClass().getDeclaredFields();

for (Field field:fields) {
 try {

  field.setAccessible(true);
  String fieldName = field.getName();
  Object fieldValue = field.get(object);
  QName fieldQName = new QName(fieldName);

  SOAPElement element = soapBody.addChildElement();
  Element.addAttribute(fieldQName, fieldValue.toString());

  //For debugging
  System.out.println("Element" + fieldValue.toString());
 } catch (Exception e) {
   // Error handling
 }

}

The element is set with the right name, but the value is null for every element. When i print fieldValue.toString the values are correct.

What am i doing wrong?





Aucun commentaire:

Enregistrer un commentaire