I have this problem for 3 days. He gets the following response from the server
<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns2:getTasks xmlns:ns2="????">
<task>
<id>25688</id>
<code>53474/CI/10/1</code>
<stateCode>allocated</stateCode>
<commissionCode>53474/CI/10</commissionCode>
<commissionId>23695</commissionId>
<commisionRegistration>2022-09-08T10:02:59.723+02:00</commisionRegistration>
<plannedRealizationFrom>2022-10-07T09:30:00.000+02:00</plannedRealizationFrom>
<plannedRealizationTo>2022-10-07T11:30:00.000+02:00</plannedRealizationTo>
<attachments>
<attachment>
<id>3580</id>
<typeId>1004</typeId>
<fileName>JPEG_20221017_143416_4079146694302606942.jpg</fileName>
<dataPresent>false</dataPresent>
<typeName>com.???.???.???.model.task.po.TaskAttachmentPo</typeName>
</attachment>
</attachments>
<anotherObject>
???
</anotherObject>
<anotherObject>
???
</anotherObject>
<anotherObject>
???
</anotherObject>
</task>
</ns2:getTasks></soapenv:Body></soapenv:Envelope>
I wanna map this into object taskMo. This class cointains others object like AttachmentMo, CommissionMo
public class TaskMo extends MobileTransferObject {
@PrimaryKey
@NonNull
@ColumnInfo
protected Long id;
@ColumnInfo
protected String code;
@TypeConverters(DatabaseConverter.class)
protected TaskTypeMo type;
@TypeConverters(DatabaseConverter.class)
protected TaskState state;
// TODO It's a hack, this table should be normalized in the near future
@ColumnInfo
protected String taskStateCode;
@ColumnInfo
protected String commissionCode;
@ColumnInfo
protected Long commissionId;
@ColumnInfo
protected String notRealizedCauseCode;
@TypeConverters(DatabaseConverter.class)
protected CommissionMo commission;
@TypeConverters(DatabaseConverter.class)
protected List<ResourceOperationMo> operations;
@TypeConverters(DatabaseConverter.class)
protected GregorianCalendar commissionRegistration;
@TypeConverters(DatabaseConverter.class)
protected GregorianCalendar plannedRealizationFrom;
@TypeConverters(DatabaseConverter.class)
protected GregorianCalendar plannedRealizationTo;
@TypeConverters(DatabaseConverter.class)
protected GregorianCalendar realizationFrom;
@TypeConverters(DatabaseConverter.class)
protected GregorianCalendar realizationTo;
@ColumnInfo
protected Integer realizationTime;
@ColumnInfo
protected String description;
@ColumnInfo
protected String notices;
@ColumnInfo
protected Integer driveTime;
@ColumnInfo
protected Double numberOfKilometers;
@TypeConverters(DatabaseConverter.class)
protected LocationMo location;
@TypeConverters(DatabaseConverter.class)
private List<AttachmentMo> attachments = new ArrayList<AttachmentMo>();
@TypeConverters(DatabaseConverter.class)
private List<AttributeGroupMo> attrGroups = new ArrayList<AttributeGroupMo>();
@ColumnInfo
private boolean moNotClearChanged = false;
@ColumnInfo
private boolean isIncorrectTaskExecutor = false;
}
I am currently using this to map the response to object
public TaskMo readTask(SoapObject x) {
if (x == null) {
return null;
}
TaskMo r = new TaskMo();
r.setId(readWsLong(x, "id"));
r.setCode(readWsString(x, "code"));
r.setStateCode(readWsString(x, "stateCode"));
r.setCommissionCode(readWsString(x, "commissionCode"));
r.setCommissionId(readWsLong(x, "commissionId"));
CommissionMo commission = readCommission(getPropertyAsSoapObjectSafely(x, "commission"));
r.setCommission(commission);
r.setType(readTaskType(getPropertyAsSoapObjectSafely(x, "taskType")));
r.setNotRealizedCauseCode(readWsString(x, "notRealizedCauseCode"));
r.setCommissionRegistration(readWsCalendar(x, "commissionRegistration"));
r.setDescription(readWsString(x, "description"));
r.setNotices(readWsString(x, "notices"));
r.setRealizationFrom(readWsCalendar(x, "realizationFrom"));
r.setRealizationTo(readWsCalendar(x, "realizationTo"));
r.setRealizationTime(readWsInteger(x, "realizationTime"));
r.setLocation(readLocation(x, "location"));
r.setDriveTime(readWsInteger(x, "driveTime"));
r.setNumberOfKilometers(readWsDouble(x, "numberOfKilometers"));
SoapObject operationsSoapObject = getPropertyAsSoapObjectSafely(x, "operations");
r.setOperations(getOperations(operationsSoapObject));
SoapObject attributes = getPropertyAsSoapObjectSafely(x, "attributeGroups");
if (attributes != null) {
List<AttributeGroupMo> attrGroups = new ArrayList<AttributeGroupMo>();
for (int i = 0; i < attributes.getPropertyCount(); i++) {
SoapObject group = (SoapObject) attributes.getProperty(i);
attrGroups.add(readAttributeGroup(group));
}
r.setAttrGroups(attrGroups);
}
r.setPlannedRealizationFrom(readWsCalendar(x, "plannedRealizationFrom"));
r.setPlannedRealizationTo(readWsCalendar(x, "plannedRealizationTo"));
SoapObject attachmentAttributes = getPropertyAsSoapObjectSafely(x, "attachments");
if (attachmentAttributes != null) {
List<AttachmentMo> attachments = new ArrayList<AttachmentMo>();
for (int i = 0; i < attachmentAttributes.getPropertyCount(); i++) {
SoapObject attachment = (SoapObject) attachmentAttributes.getProperty(i);
attachments.add(readAttachment(attachment));
}
r.setAttachments(attachments);
}
r.moClearChanged();
return r;
}
I would like to change this mechanism to something that will automatically create an object from the response (for example Jackson ObjectMapper)
httpTransport.call(getSoapActionPrefix() + method, envelope); // send request
Object result = envelope.getResponse(); // get response
List<Map<String, String>> map = parseTest(httpTransport.responseDump, "task");
final ObjectMapper mapper = new ObjectMapper(); // jackson's objectmapper
// final TaskMo pojo = mapper.convertValue(map.toString(), TaskMo.class);
Im getting exception:
java.lang.IllegalArgumentException: Unrecognized field "commonName" (class com.softelnet.ksavi.android.model.TaskMo), not marked as ignorable (27 known properties: "commissionRegistration", "numberOfKilometers"....)
CommonName is part of Object which cointains TaskMo
I would be very grateful for a hint on how to do this