1

I am trying to send a complex object through a soap service call in an android application. I am getting a quite weird error.

The class that I am trying to serialize and send (and the one that are included to it) is the following:

public class TSavedMessage extends BaseObject{
public static Class TSAVEDMESSAGE_CLASS = new TSavedMessage().getClass();
protected String sToken;
protected String dateDeferredDelivery;
protected int idDepartment;
protected boolean bDraft;
protected String txtRelationsType;
protected String txtRelatedIds;
protected int idForwardOf;
protected int idReplyOf;
protected String numPriority;
protected boolean bReadReceipt;
protected boolean bDeliveryReport;
protected String txtKeywords;
protected int numTimeOffset;
protected String txtTimeZone;
protected String txtSubject;
protected String txtBody;
protected TRecipient[] recipients;

public TSavedMessage() {
}

public TSavedMessage(String sToken, String dateDeferredDelivery, int idDepartment, boolean bDraft, String txtRelationsType, String txtRelatedIds, int idForwardOf, int idReplyOf, String numPriority, boolean bReadReceipt, boolean bDeliveryReport, String txtKeywords, int numTimeOffset, String txtTimeZone, String txtSubject, String txtBody, TRecipient[] recipients, int[] vesselRelations) {
    this.sToken = sToken;
    this.dateDeferredDelivery = dateDeferredDelivery;
    this.idDepartment = idDepartment;
    this.bDraft = bDraft;
    this.txtRelationsType = txtRelationsType;
    this.txtRelatedIds = txtRelatedIds;
    this.idForwardOf = idForwardOf;
    this.idReplyOf = idReplyOf;
    this.numPriority = numPriority;
    this.bReadReceipt = bReadReceipt;
    this.bDeliveryReport = bDeliveryReport;
    this.txtKeywords = txtKeywords;
    this.numTimeOffset = numTimeOffset;
    this.txtTimeZone = txtTimeZone;
    this.txtSubject = txtSubject;
    this.txtBody = txtBody;
    this.recipients = recipients;
}

public String getSToken() {
    return sToken;
}

public void setSToken(String sToken) {
    this.sToken = sToken;
}

public String getDateDeferredDelivery() {
    return dateDeferredDelivery;
}

public void setDateDeferredDelivery(String dateDeferredDelivery) {
    this.dateDeferredDelivery = dateDeferredDelivery;
}

public int getIdDepartment() {
    return idDepartment;
}

public void setIdDepartment(int idDepartment) {
    this.idDepartment = idDepartment;
}

public boolean isBDraft() {
    return bDraft;
}

public void setBDraft(boolean bDraft) {
    this.bDraft = bDraft;
}

public String getTxtRelationsType() {
    return txtRelationsType;
}

public void setTxtRelationsType(String txtRelationsType) {
    this.txtRelationsType = txtRelationsType;
}

public String getTxtRelatedIds() {
    return txtRelatedIds;
}

public void setTxtRelatedIds(String txtRelatedIds) {
    this.txtRelatedIds = txtRelatedIds;
}

public int getIdForwardOf() {
    return idForwardOf;
}

public void setIdForwardOf(int idForwardOf) {
    this.idForwardOf = idForwardOf;
}

public int getIdReplyOf() {
    return idReplyOf;
}

public void setIdReplyOf(int idReplyOf) {
    this.idReplyOf = idReplyOf;
}

public String getNumPriority() {
    return numPriority;
}

public void setNumPriority(String numPriority) {
    this.numPriority = numPriority;
}

public boolean isBReadReceipt() {
    return bReadReceipt;
}

public void setBReadReceipt(boolean bReadReceipt) {
    this.bReadReceipt = bReadReceipt;
}

public boolean isBDeliveryReport() {
    return bDeliveryReport;
}

public void setBDeliveryReport(boolean bDeliveryReport) {
    this.bDeliveryReport = bDeliveryReport;
}

public String getTxtKeywords() {
    return txtKeywords;
}

public void setTxtKeywords(String txtKeywords) {
    this.txtKeywords = txtKeywords;
}

public int getNumTimeOffset() {
    return numTimeOffset;
}

public void setNumTimeOffset(int numTimeOffset) {
    this.numTimeOffset = numTimeOffset;
}

public String getTxtTimeZone() {
    return txtTimeZone;
}

public void setTxtTimeZone(String txtTimeZone) {
    this.txtTimeZone = txtTimeZone;
}

public String getTxtSubject() {
    return txtSubject;
}

public void setTxtSubject(String txtSubject) {
    this.txtSubject = txtSubject;
}

public String getTxtBody() {
    return txtBody;
}

public void setTxtBody(String txtBody) {
    this.txtBody = txtBody;
}

public TRecipient[] getRecipients() {
    return recipients;
}

public void setRecipients(TRecipient[] recipients) {
    this.recipients = recipients;
}

public Object getProperty(int index) {
    switch (index) {
    case 0:
        return sToken;
    case 1: 
        return dateDeferredDelivery;
    case 2:
        Integer iDepartment = new Integer(idDepartment);
        return iDepartment;
    case 3:
        Boolean isDraft = new Boolean(bDraft);
        return isDraft;
    case 4:
        return txtRelationsType;
    case 5:
        return txtRelatedIds;
    case 6:
        Integer iForwardOf = new Integer(idForwardOf);
        return iForwardOf;
    case 7:
        Integer iReplyOf = new Integer(idReplyOf);
        return iReplyOf;
    case 8:
        return numPriority;
    case 9:
        Boolean isReadReceipt = new Boolean(bReadReceipt);
        return isReadReceipt;
    case 10:
        Boolean isDeliveryReport = new Boolean(bDeliveryReport);
        return isDeliveryReport;
    case 11:
        return txtKeywords;
    case 12:
        Integer iTimeOffset = new Integer(numTimeOffset);
        return iTimeOffset;
    case 14:
        return txtTimeZone;
    case 15:
        return txtSubject;
    case 16:
        return txtBody;
    case 17:
        return recipients; // complex type
    default:
        return null;
    }
}

public int getPropertyCount() {
    return 18;
}

public void getPropertyInfo(int index, Hashtable properties, PropertyInfo info) {
    switch (index) {
    case 0:
        info.type = PropertyInfo.STRING_CLASS;
        info.name = "sToken";
        break;
    case 1: 
        info.type = PropertyInfo.STRING_CLASS;
        info.name = "dateDeferredDelivery";
        break;
    case 2:
        info.type = PropertyInfo.INTEGER_CLASS;
        info.name = "idDepartment";
        break;
    case 3:
        info.type = PropertyInfo.BOOLEAN_CLASS;
        info.name = "bDraft";
        break;
    case 4:
        info.type = PropertyInfo.STRING_CLASS;
        info.name = "txtRelationsType";
        break;
    case 5:
        info.type = PropertyInfo.STRING_CLASS;
        info.name = "txtRelatedIds";
        break;
    case 6:
        info.type = PropertyInfo.INTEGER_CLASS;
        info.name = "idForwardOf";
        break;
    case 7:
        info.type = PropertyInfo.INTEGER_CLASS;
        info.name = "idReplyOf";
        break;
    case 8:
        info.type = PropertyInfo.STRING_CLASS;
        info.name = "numPriority";
        break;
    case 9:
        info.type = PropertyInfo.BOOLEAN_CLASS;
        info.name = "bReadReceipt";
        break;
    case 10:
        info.type = PropertyInfo.BOOLEAN_CLASS;
        info.name = "bDeliveryReport";
        break;
    case 11:
        info.type = PropertyInfo.STRING_CLASS;
        info.name = "txtKeywords";
        break;
    case 12:
        info.type = PropertyInfo.INTEGER_CLASS;
        info.name = "numTimeOffset";
        break;
    case 14:
        info.type = PropertyInfo.STRING_CLASS;
        info.name = "txtTimeZone";
        break;
    case 15:
        info.type = PropertyInfo.STRING_CLASS;
        info.name = "txtSubject";
        break;
    case 16:
        info.type = PropertyInfo.STRING_CLASS;
        info.name = "txtBody";
        break;
    case 17:
        info.type = PropertyInfo.VECTOR_CLASS;
        info.name = "recipients"; // complex type
        break;
    default:
        break;
    }       
}

public void setProperty(int index, Object value) {
    switch (index) {
    case 0:
        sToken = value.toString();
        break;
    case 1: 
        dateDeferredDelivery = value.toString();
        break;
    case 2:
        idDepartment = Integer.parseInt(value.toString());
        break;
    case 3:
        if(value.toString().equalsIgnoreCase("false")) bDraft = false;
        else bDraft = true;
        break;
    case 4:
        txtRelationsType = value.toString();
        break;
    case 5:
        txtRelatedIds = value.toString();
        break;
    case 6:
        idForwardOf = Integer.parseInt(value.toString());
        break;
    case 7:
        idReplyOf = Integer.parseInt(value.toString());
        break;
    case 8:
        numPriority = value.toString();
        break;
    case 9:
        if(value.toString().equalsIgnoreCase("false")) bReadReceipt = false;
        else bReadReceipt = true;
        break;
    case 10:
        if(value.toString().equalsIgnoreCase("false")) bDeliveryReport = false;
        else bDeliveryReport = true;
        break;
    case 11:
        txtKeywords = value.toString();
        break;
    case 12:
        numTimeOffset = Integer.parseInt(value.toString());
        break;
    case 14:
        txtTimeZone = value.toString();
        break;
    case 15:
        txtSubject = value.toString();
        break;
    case 16:
        txtBody = value.toString();
        break;
    case 17:
        recipients = (TRecipient[]) value; // complex type
        break;
    default:
        break;
    }
}

}

public class TRecipient extends BaseObject{
public static Class TRECIPIENT_CLASS = new TRecipient().getClass();
protected int idRecipient;
protected String txtRealAddress;
protected String Visibility;

public TRecipient() {
}

public TRecipient(int idRecipient, String txtRealAddress, String visibility) {
    this.idRecipient = idRecipient;
    this.txtRealAddress = txtRealAddress;
    this.Visibility = visibility;
}

public int getIdRecipient() {
    return idRecipient;
}

public void setIdRecipient(int idRecipient) {
    this.idRecipient = idRecipient;
}

public String getTxtRealAddress() {
    return txtRealAddress;
}

public void setTxtRealAddress(String txtRealAddress) {
    this.txtRealAddress = txtRealAddress;
}

public String getVisibility() {
    return Visibility;
}

public void setVisibility(String visibility) {
    this.Visibility = visibility;
}

public Object getProperty(int index) {
    switch (index) {
    case 0:
        Integer iRecipient = new Integer(idRecipient);
        return iRecipient;
    case 1: 
        return txtRealAddress;
    case 2:
        return Visibility;
    default:
        return null;
    }
}

public int getPropertyCount() {
    return 3;
}

public void getPropertyInfo(int index, Hashtable properties, PropertyInfo info) {
    switch (index) {
    case 0:
        info.type = PropertyInfo.INTEGER_CLASS;
        info.name = "idRecipient";
        break;
    case 1:
        info.type = PropertyInfo.STRING_CLASS;
        info.name = "txtRealAddress";
        break;
    case 2:
        info.type = PropertyInfo.STRING_CLASS;
        info.name = "Visibility";
        break;
    default:
        break;
    }
}

public void setProperty(int index, Object value) {
    switch (index) {
    case 0:
        idRecipient = Integer.parseInt(value.toString());
        break;
    case 1: 
        txtRealAddress = value.toString();
        break;
    case 2:
        Visibility = value.toString();
        break;
    default:
        break;
    }
}

}

The method that sends the request is the following:

            TSavedMessage msgTemp = new TSavedMessage();
        msgTemp.setSToken(LoginActivity.sToken);
        DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        Date date = new Date();
        msgTemp.setDateDeferredDelivery(dateFormat.format(date));
        msgTemp.setIdDepartment(datasource.getDepartmentID(departmentString));
        msgTemp.setBDraft(false);
        msgTemp.setTxtRelationsType("");
        msgTemp.setTxtRelatedIds("");
        msgTemp.setIdForwardOf(params[1]);
        msgTemp.setIdReplyOf(params[2]);
        msgTemp.setNumPriority("Normal");
        msgTemp.setBReadReceipt(false);
        msgTemp.setBDeliveryReport(false);
        msgTemp.setTxtKeywords(keywords.getText().toString());
        msgTemp.setNumTimeOffset(0);
        msgTemp.setTxtTimeZone("0");
        msgTemp.setTxtSubject(subject.getText().toString());
        msgTemp.setTxtBody(body.getText().toString());
        TRecipient[] recarrayTemp = new TRecipient[1];
        recarrayTemp[0] = new TRecipient(0, "nickvoulgaris@hotmail.com", "To");
        msgTemp.setRecipients(recarrayTemp);

        SoapObject recipients = new SoapObject(LoginActivity.NAMESPACE, "Recipients");
        SoapObject recarray[] = new SoapObject[1];
        for (int i = 0; i < 1; i++){
            recarray[i] = new SoapObject(BaseObject.NAMESPACE, "TRecipient");
            recarray[i].addProperty("idRecipient", Integer.toString(0));
            recarray[i].addProperty("txtRealAddress", "nickvoulgaris@hotmail.com");
            recarray[i].addProperty("Visibility", "To");
            recipients.addProperty("TRecipient", recarray[i]);
        }

        SoapObject msg = new SoapObject(BaseObject.NAMESPACE, "MessageToSend");
        msg.addProperty("sToken", LoginActivity.sToken);
        msg.addProperty("dateDeferredDelivery", msgTemp.getDateDeferredDelivery());
        msg.addProperty("idDepartment", Integer.toString(msgTemp.getIdDepartment()));
        msg.addProperty("bDraft", "false");
        msg.addProperty("txtRelationsType", Integer.toString(0));
        msg.addProperty("txtRelatedIds", Integer.toString(0));
        msg.addProperty("idForwardOf", Integer.toString(0));
        msg.addProperty("idReplyOf", Integer.toString(0));
        msg.addProperty("numPriority", msgTemp.getNumPriority());
        msg.addProperty("bReadReceipt", "false");
        msg.addProperty("bDeliveryReport", "false");         
        msg.addProperty("txtKeywords", msgTemp.getTxtKeywords());
        msg.addProperty("numTimeOffset", msgTemp.getNumTimeOffset());
        msg.addProperty("txtTimeZone", msgTemp.getTxtTimeZone());
        msg.addProperty("txtSubject", msgTemp.getTxtSubject());
        msg.addProperty("txtBody", msgTemp.getTxtBody());
        msg.addProperty("Recipients", recipients);

        SoapObject rpc = new SoapObject(BaseObject.NAMESPACE, METHOD_NAME);       
        rpc.addProperty("sToken", LoginActivity.sToken);
        rpc.addProperty("MessageToSend", msg);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.bodyOut = rpc;
        envelope.dotNet = true;
        envelope.encodingStyle = SoapSerializationEnvelope.XSD;

        try {
            HttpTransportSE androidHttpTransport = new HttpTransportSE(LoginActivity.URL); 
            androidHttpTransport.debug = true;
            androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
            androidHttpTransport.call(SOAP_ACTION, envelope);
            System.out.println("=== " + envelope.getResponse().toString());                 
        }
        catch(XmlPullParserException e) {
            e.printStackTrace();
        }
        catch(IOException e) {
            e.printStackTrace();
        }

Finally, the error that I'm getting is this one:

    SoapFault - faultcode: 'EConvertError' faultstring: '''0nickvoulgaris@hotmail.comTo'' is not a valid integer value' 

faultactor: 'null' detail: null

It is quite unfortunate that the error points me to nowhere. I cannot understand why is trying to pass these 3 fields as an Integer. Also what troubles me is the fact that there is a triple quote in the left hand side and a double one in the right hand side.

Any thoughts could prove extremely valuable. Thanks in advance.

Also, the soap object that this code generates and tries to send seems perfectly ok. It is the following:

MobSaveMessage{
sToken=MOB-2704FB8FFBC946469408A3BEE90CA163; 
MessageToSend=MessageToSend{
    sToken=MOB-2704FB8FFBC946469408A3BEE90CA163; 
    dateDeferredDelivery=2012/07/25 13:30:36; 
    idDepartment=18; 
    bDraft=false; 
    txtRelationsType=0; 
    txtRelatedIds=0; 
    idForwardOf=0; 
    idReplyOf=0; 
    numPriority=Normal; 
    bReadReceipt=false; 
    bDeliveryReport=false; 
    txtKeywords=key; 
    numTimeOffset=0; 
    txtTimeZone=0; 
    txtSubject=sub; 
    txtBody=mail;
    Recipients=Recipients{
        TRecipient=TRecipient{
            idRecipient=0; 
            txtRealAddress=nickvoulgaris@hotmail.com; 
            Visibility=To; 
        }; 
    }; 
}; 

}

4

1 回答 1

2

毕竟,我们收到了与规范一起发送给我们的错误版本的 WSDL 文件。如果我给任何人带来麻烦,我真的很抱歉。真的不是我的错。我只是在回答,以防有人遇到问题。

于 2012-12-30T19:16:01.083 回答