SOAP web client on Android
Posted
by BANSAL MOHIT
on Stack Overflow
See other posts from Stack Overflow
or by BANSAL MOHIT
Published on 2010-04-08T23:00:00Z
Indexed on
2010/04/08
23:03 UTC
Read the original article
Hit count: 777
android
Hi
I am trying to create a web service client for the android but i am stuck really bad Attached is my code and WSDL file. Please help
/* * To change this template, choose Tools | Templates * and open the template in the editor. */
package org.me.androidapplication1;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;
import org.xmlpull.v1.XmlPullParserException;
/** * * @author bansal */ public class MainActivity extends Activity {
private String SOAP_ACTION = "http://src/getNews";
private String METHOD_NAME = "getNews";
private String NAMESPACE = "http://src/";
private static final String URL ="http://128.205.201.202:8080/RssService /RssServiceService?WSDL";
/** Called when the activity is first created. */ @Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
TextView tv = new TextView(this);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("ticker","NASDAQ:INFY");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapPrimitive p = (SoapPrimitive) envelope.getResponse();
tv.setText("Response " + p);
} catch (Exception ex) {
ex.printStackTrace();
}
setContentView(tv);
// ToDo add your GUI initialization code here
}
}
Thanks
© Stack Overflow or respective owner