Web service on Android Phone using VB.net

Put your problem here if it does not fit any of the other categories.

Web service on Android Phone using VB.net

Postby tamperen » Fri Apr 24, 2009 4:38 am

my hello world is working fine but when i add parameters it does not seems to process. now i am stuck . :D

my java code for android is

package web.WS.com;

import java.io.IOException;
import java.util.Date;

import org.kobjects.isodate.IsoDate;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlSerializer;

import android.app.Activity;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.TextView;

public class WS extends Activity
private static final String SOAP_ACTION = "http://tempuri.org/HelloWorld";
private static final String METHOD_NAME = "HelloWorld";
private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = "";
private Object resultsRequestSOAP = null;
public String strpath;
private EditText mPath;
public void onCreate(Bundle icicle)
TextView tv = new TextView(this);
String Hea = "Super";

// mPath=(EditText)findViewById(R.id.path);

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

// SoapObject parameters = new SoapObject(NAMESPACE, METHOD_NAME);
// parameters.addProperty("help", "help");
// request.addProperty("A", );

// request.setProperty(5, "A");

// request.getProperty("A");

// request.setProperty(request.getProperty("A"), "TANNNNNER");

/// request.addProperty("firstname", "John");
request.addProperty("A", "A");

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

envelope.dotNet = true;
tv.setText(Hea+"HUNTER UpDated");


HttpTransportSE HttpTransport = new HttpTransportSE(URL);

tv.setText(Hea+"HUNTER UpDated many times");


//Parse Response
SoapObject resultsRequestSOAP1 = (SoapObject) envelope.bodyIn;

tv.setText(Hea+"HUNTER UpDated many times afther try");
HttpTransport.call(SOAP_ACTION, envelope);

tv.setText(Hea+"HUNTER UpDated many times afther try3");

resultsRequestSOAP = envelope.getResponse();
tv.setText(resultsRequestSOAP+Hea+" HUNTER UpDated many times afther try the before results");

// String[] results = (String[]) resultsRequestSOAP ;
// tv.setText(Hea+" HUNTER UpDated many times afther try the before results scuessful result");
// tv.setText( results+"LOL"+resultsRequestSOAP1);
//tv.setText(Hea+"HUNTER UpDated many times afther try the before results scuessful result nothing come out");

catch (Exception E)
E.printStackTrace ();

tv.setText("ERROR:" + E.getClass().getName() + ": " + E.getMessage());

// tv.setText("exception ERROR!");

/* public AndroidServiceConnection(String url)throws IOException
bufferStream = null;
HttpURL httpURL = new HttpURL(url);
HostConfiguration host = new HostConfiguration();
host.setHost(httpURL.getHost(), httpURL.getPort());

ContentResolver contentResolver = getContentResolver();
String http_proxy = Settings.System.getString(contentResolver,
String[] proxyDetails = http_proxy.split(":");
Integer proxyPort = new Integer(proxyDetails[1]);
host.setProxy(proxyDetails[0], proxyPort);

connection = connectionManager.getConnection(host);
postMethod = new PostMethod(url);
private SoapObject table = null; // Its the table of a DataSet
private SoapObject client = null; // Its the client pettition to the web service
private SoapObject tableRow = null; // Gets the information of a row from the table DataSet
private SoapObject responseBody = null; // Its the whole response of the WebService
private HttpTransportSE transport = null; // Its whta is used to make the call to the WebService
private SoapSerializationEnvelope sse = null;

sse = new SoapSerializationEnvelope(SoapEnvelope.VER11); // SOAP version is indicated here. Version 11 works nice
sse.addMapping("http://tempuri.org/", "HelloWorld", this.getClass());
sse.dotNet = true; // We stablish we sill be working with .NET webservices
transport = new HttpTransport("");
transport.setXmlVersionTag("<?xml version="1.0" encoding="UTF-8"?>");
transporte.debug = debug; // Set it to either use transport.dumpRequest or dumpReponse to see the xml of the webservice request of response

//Here we set who are we gonna call, give the method arguments and do the call
client = new SoapObject("http://tempuri.org/", "HelloWorld");
// You can add as many properties as many as you need. I'd say that you set your webservices method to recieve only strings and do the convertions on you webservice. Its quite hard work with primitive values
//client.addProperty(String, "john");
sse.bodyOut = client;
transporte.call("", sse);

//We'll get the whole XML reponse with all the information
responseBody = (SoapObject) sse.getResponse();
// Now, the reponse works as a Vector. On position 0 we have the information of the Reponse while in position 1 we get the info we requested. So we get rid of the information reponse and lets grab the info we requested
responseBody = (SoapObject) responseBody.getProperty(1);
// And now, we have the n tables the WebService returned to us with the information, but still we can't access the info, so we'll get one of the tables separated. We'll use a very different variable for not to lose the whole info the webservice sended us. Once again, the tables are contained on a Vector. Lets grab the first one
table = (SoapObject) responseBody.getProperty(0);
// Now we have the table, but still can't use the info, soooo, lets grab a row individually
tableRow = (SoapObject) table.getProperty(0);


public Object readInstance(XmlPullParser parser, String namespace, String name,
PropertyInfo expected) throws IOException, XmlPullParserException {
return IsoDate.stringToDate(parser.nextText(), IsoDate.DATE_TIME);

public void writeInstance(XmlSerializer writer, Object obj) throws IOException {
writer.text(IsoDate.dateToString((Date) obj, IsoDate.DATE_TIME));


and the web service is

<WebMethod()> _
Public Function HelloWorld(ByVal A As String) As String

Return "Hello World " + A

End Function

:D :D :) :D
Posts: 2
Joined: Mon Apr 06, 2009 7:19 am


Return to Other Coding-Problems

Who is online

Users browsing this forum: MSNbot Media and 15 guests