Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to do the Parsing of SOAP Response
    primarykey
    data
    text
    <p>I am new in android development.I am getting the SOAP response but I do not know that how to do the parsing of values of the SOAP Response. Actually I am trying to parse the String "Emotion" from the response. Please find my XML document and response here <a href="http://letsmote.com:8087/EmoteSAPI.asmx?op=GetEmotionList" rel="nofollow">http://letsmote.com:8087/EmoteSAPI.asmx?op=GetEmotionList</a> Here is my code </p> <pre><code>public class EmotionList extends Activity { public final String NAMESPACE = "http://tempuri.org"; public final String URL = "http://letsmote.com:8087/EmoteSAPI.asmx"; public final String SOAP_ACTION = "http://tempuri.org/GetEmotionList"; public final String METHOD_NAME = "GetEmotionList"; //SharedPreferences sp; String[] Emotionlist; EditText edt; Button GetEmotion; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_emotion_list); // TODO Auto-generated method stub SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); Element[] header = new Element[1]; header[0] = new Element().createElement("http://tempuri.org/","SecurityInfo"); Element APIkey = new Element().createElement(null,"n0:APIKey"); APIkey.addChild(Node.TEXT,"BcodTestAPI"); header[0].addChild(Node.ELEMENT,APIkey); Element user = new Element().createElement(null,"n0:UserID"); user.addChild(Node.TEXT,"bcod"); header[0].addChild(Node.ELEMENT,user); Element passid = new Element().createElement(null,"n0:Password"); passid.addChild(Node.TEXT, "bcod"); header[0].addChild(Node.ELEMENT, passid); // add header to envelope envelope.headerOut = header; envelope.dotNet = true; envelope.setOutputSoapObject(request); HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); try { androidHttpTransport.call(SOAP_ACTION, envelope); //SoapPrimitive response = (SoapPrimitive)envelope.getResponse(); Log.e("myApp",envelope.getResponse().toString()); SoapObject response = (SoapObject) envelope.getResponse(); Log.e(" ","----------Response----------"+response.toString()); System.out.println("===Response==="); SoapObject CinemaCode; SoapObject pii = (SoapObject)response.getAttribute("Emotion"); Log.e(" ","----------Response1----------"+response.toString()); CinemaCode = (SoapObject)pii.getProperty(1); String []categories = new String [CinemaCode.getPropertyCount()]; String []Emotions = new String[1000]; for (int i = 0; i &lt; categories.length; i++) { SoapObject list = (SoapObject)CinemaCode.getProperty(i); Emotions[i] = list.getProperty(2).toString(); Log.e("","Emotions Are: = "+Emotions[i]); } }catch(Exception e) { } } </code></pre> <p>Here is the response which I am getting....</p> <p>09-25 11:38:20.357: E/(626): ----------Response----------anyType{Emotions=anyType{Emotion=Joy; Color=#9370DB; EmotionId=17; IsHappyEmotion=true; }; Emotions=anyType{Emotion=Freedom; Color=#800080; EmotionId=12; IsHappyEmotion=true; }; Emotions=anyType{Emotion=Love; Color=#8B008B; EmotionId=19; IsHappyEmotion=true; }; Emotions=anyType{Emotion=Passion; Color=#008080; EmotionId=21; IsHappyEmotion=true; }; Emotions=anyType{Emotion=Enthusiasm; Color=#B8860B; EmotionId=10; IsHappyEmotion=true; }; Emotions=anyType{Emotion=Optimism; Color=#696969; EmotionId=20; IsHappyEmotion=true; }; Emotions=anyType{Emotion=Hopefulness; Color=#98F5FF; EmotionId=15; IsHappyEmotion=true; }; Emotions=anyType{Emotion=Contentment; Color=#0000FF; EmotionId=4; IsHappyEmotion=true; }; Emotions=anyType{Emotion=Boredom; Color=#8A2BE2; EmotionId=3; IsHappyEmotion=false; }; Emotions=anyType{Emotion=Pessimism; Color=#48D1CC; EmotionId=22; IsHappyEmotion=true; }; Emotions=anyType{Emotion=Frustration; Color=#FFC0CB; EmotionId=24; IsHappyEmotion=false; }; Emotions=anyType{Emotion=Disappointment; Color=#D2691E; EmotionId=7; IsHappyEmotion=false; }; Emotions=anyType{Emotion=Doubt; Color=#CAFF70; EmotionId=9; IsHappyEmotion=false; }; Emotions=anyType{Emotion=Worry; Color=#008000; EmotionId=23; IsHappyEmotion=false; }; Emotions=anyType{Emotion=Blame; Color=#7CFC00; EmotionId=2; IsHappyEmotion=false; }; Emotions=anyType{Emotion=Discouragement; Color=#ADFF2F; EmotionId=8; IsHappyEmotion=false; }; Emotions=anyType{Emotion=Jealousy; Color=#006400; EmotionId=16; IsHappyEmotion=false; }; Emotions=anyType{Emotion=Guilt; Color=#FFFF00; EmotionId=13; IsHappyEmotion=false; }; Emotions=anyType{Emotion=Loneliness; Color=#BDB76B; EmotionId=18; IsHappyEmotion=false; }; Emotions=anyType{Emotion=Fear; Color=#FF8C00; EmotionId=11; IsHappyEmotion=false; }; Emotions=anyType{Emotion=Anger; Color=#FF0000; EmotionId=1; IsHappyEmotion=false; }; Emotions=anyType{Emotion=Depression; Color=#8B0000; EmotionId=5; IsHappyEmotion=false; }; Emotions=anyType{Emotion=Despair; Color=#CD5C5C; EmotionId=6; IsHappyEmotion=false; }; Emotions=anyType{Emotion=Hatred; Color=#800000; EmotionId=14; IsHappyEmotion=false; }; }</p> <p>Thanks in Advance</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload