-1

Ceci est mon code de service Web. Je ne sais pas comment analyser la réponse au savon. Que devrais-je faire? Je ne sais même pas que c'est JSON ou Xml. Alors, dites-moi quel type de réponse c'est? ma réponse comme celui-cicomment analyser la réponse soapobject d'asp.net

anyType {details_produit = {anyType p_id = 129; p_name = FFFF; nom_C = gggg;};}

public class MyAsyncTask extends AsyncTask<String, String , String> 
{ 

    @Override 
    protected void onPostExecute(String arrPersons) 
    { 
     uid.setText(arrPersons);    
    } 

    @Override 
     protected void onProgressUpdate(String... text) 
    { 

    uid.setText(text[0]); 

    } 

    @Override 
    protected String doInBackground(String... arg0) 
    { 

     SOAP_ADDRESS=""; 

     request=new SoapObject(WSDL_TARGET_NAMESPACE, OPERATION_NAME); 
     publishProgress("Loading contents..."); 
     PropertyInfo pi=new PropertyInfo(); 
     pi.setName("PID"); 
     pi.setValue(Integer.parseInt(arg0[1])); 
     pi.setType(String.class); 
     request.addProperty(pi); 
     pi=new PropertyInfo(); 

     envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11); 

     envelope.dotNet=true; 
     envelope.setOutputSoapObject(request); 

     httpTransport=new HttpTransportSE(SOAP_ADDRESS); 
     try 
     { 
      httpTransport.call(SOAP_ACTION, envelope); 

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


      for (int i = 0; i < response.getPropertyCount(); i++) 
      { 
       Object property = response.getProperty(i); 
       if (property instanceof SoapObject) 
       { 
        SoapObject category_list = (SoapObject) property; 
        String returnString1 = category_list.getProperty(0).toString(); 

       } 
      } 

     } 
     catch (Exception e) 
     { 

      returnString1 = e.getMessage(); 
     } 
     return returnString1; 

    } 

} 

Répondre

0

Le format pourrait dans le tableau de données format retour. vous feriez mieux de montrer votre code de services Web que vous avez créé sur asp.net

0

Ceci est mon code asp pour le service Web

public class qr : System.Web.Services.WebService { 

[WebMethod] 
public DataTable findData(String PID) 
{ 
    String constr = ConfigurationManager.ConnectionStrings["ConnectionString2"].ConnectionString; 
    using (SqlConnection con = new SqlConnection(constr)) 
    { 
     using (SqlCommand cmd = new SqlCommand("SELECT * FROM Product_Details WHERE P_id = @P_id")) 
     { 
      cmd.Parameters.AddWithValue("@P_id", PID); 
      cmd.Connection = con; 
      con.Open(); 
      cmd.ExecuteNonQuery(); 
      using (SqlDataAdapter sda = new SqlDataAdapter()) 
      { 
       sda.SelectCommand = cmd; 
       using (DataTable dt = new DataTable()) 
       { 
        dt.TableName = "Product_Details"; 
        sda.Fill(dt); 
        return dt; 
       } 
      } 
     } 
    } 
}