You can use a JSON serializer like Jackson to do this. Ideally the object would have relevant getters for the data you mention that you need to remain intact. Even if the data is private, you can tell Jackson to serialize it anyways using reflection.
ObjectMapper mapper = new ObjectMapper();
// You can use these options if the object doesn't have getters
// for fields that need to be saved, and the fields are private.
mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
// Save the string representation somewhere
String yourObjectAsAJsonString = mapper.writeValueAsString(yourObject);
// Load the object back from the string representation
YourObject yourObjectDeserialized = mapper.readValue(yourObjectAsAJsonString, YourObject.class);
Your issue with the java.io.NotSerializableException
is probably not under your control because you are receiving the object via SOAP, so you can't make it implement Serializable
after the fact. Using a JSON serializer like Jackson can help you get around this problem.