我确实在 android 上调用了 WCF Web 服务,我调用的函数返回一个“个人”,我得到以下响应肥皂:
<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代码:
try {
androidHttpTransport.call(SOAP_ACTION + GetPersonnel_METHOD, envelope);
SoapObject result = (SoapObject)envelope.getResponse();
Log.d("personnel : ", result.toString());
return result.toString();
我想解析这个结果“结果”(一个复杂的对象)具有类personalDTO的形式
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;
}
}
我尝试了几个,但我从来没有找到解决这个问题的方法。