2

I did call a WCF web service on android, the function I called returns a "personal", I got the following response soap:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
  <GetPersonnelByPasswordResponse xmlns="http://mycompany.com/PersonnelService">
     <GetPersonnelByPasswordResult z:Id="i1" xmlns:a="http://schemas.datacontract.org/2004/07/DataAccessLayer.Modele" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/">
        <EntityKey z:Id="i2" xmlns="http://schemas.datacontract.org/2004/07/System.Data.Objects.DataClasses" xmlns:b="http://schemas.datacontract.org/2004/07/System.Data">
           <b:EntityContainerName>DSS_SOTUBIEntities</b:EntityContainerName>
           <b:EntityKeyValues>
              <b:EntityKeyMember>
                 <b:Key>PersonnelID</b:Key>
                 <b:Value i:type="c:long" xmlns:c="http://www.w3.org/2001/XMLSchema">2</b:Value>
              </b:EntityKeyMember>
           </b:EntityKeyValues>
           <b:EntitySetName>Personnels</b:EntitySetName>
        </EntityKey>
        <a:Adresse>ariana</a:Adresse>
        <a:Email>zied@hotmail.fr</a:Email>
        <a:Login>admin</a:Login>
        <a:Matricule>1</a:Matricule>
        <a:Nom>ben mahmoud</a:Nom>
        <a:Password>admin</a:Password>
        <a:PersonnelID>2</a:PersonnelID>
        <a:Prenom>zied</a:Prenom>
        <a:ProfilID>1</a:ProfilID>
        <a:Tel>123</a:Tel>
     </GetPersonnelByPasswordResult>
  </GetPersonnelByPasswordResponse>

java code I used:

try {

androidHttpTransport.call(SOAP_ACTION + GetPersonnel_METHOD, envelope);


 SoapObject result =                          (SoapObject)envelope.getResponse();

            Log.d("personnel : ", result.toString());

            return result.toString();

I want to parse this result "result" (a complex object) has the form of a class personnelDTO

public class PersonnelDTO {


public long PersonnelID ;

 public void setPersonnelID(Long personnelID) {
       this.PersonnelID = personnelID;
    }

 public long getPersonnelID() {
       return PersonnelID;
    }

public String Login ;

 public void setLogin(String login) {
       this.Login = login;
    }

 public String getLogin() {
       return Login;
    }

public String Password ;

 public void setPassword(String password) {
       this.Password = password;
    }

 public String getPassword() {
       return Password;
    }


public Integer ProfilID ;

public void setProfilID (Integer profilID)
{
   this.ProfilID = profilID ;
}

public Integer getProfilID (){
    return ProfilID;
}

public String Nom ;

public void setNom (String nom){
    this.Nom = nom;
}

public String getNom(){
    return Nom;
}

public String Prenom ;

public void setPrenom (String prenom){
    this.Prenom = prenom;
}
public String getPrenom(){
    return Prenom;
}

public Integer Tel ;

public void setTel(Integer tel){
    this.Tel = tel;
}
public Integer getTel(){
    return Tel;
}

public String Email ;

public void setEmail (String email){
    this.Email = email;

}
public String getEmail(){

    return Email;
}

public String Adresse ;

public void setAdresse(String adresse)
{
    this.Adresse = adresse;
}
public String getAdresse(){
    return Adresse;
}

public Integer Matricule ;

public void setMatricule (Integer matricule){
    this.Matricule = matricule;
}

public Integer getMatricule (){
    return Matricule;
}
}

I tried with several, but I never found a solution to this problem.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Ibra
  • 31
  • 3
  • Check if [this][1] thread helps you. [1]: http://stackoverflow.com/questions/13579594/parsing-soap-response-in-android-using-ksoap2 – CoffeeBeans Aug 13 '13 at 14:14
  • use SimpleXML. http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php – Ali Amini Jul 09 '19 at 09:21
  • Try the following: 1. Copy over your response and paste it here https://www.freeformatter.com/xsd-generator.html#ad-output to generate an xsd from your SOAP response. You could use an IDE or any other tool to generate the xsd. 2. Generate Java classes from your xsd using xjc your_file.xsd 3. Now use JAXB to map your response to these classes. – sechanakira Jul 09 '19 at 09:25

0 Answers0