Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai guys,

I want one help from you guys,

I am getting the result that are in the server using the web service in android and SOAP but the problem is that am receive the result but not in an proper manner i want the perticular coloumn data in to the textView.Like this:BuSnumber-210,Source-xyz,Destination-vbk like this how to do this in android???I have pasted my codes below...
package com.example.newr;

import java.sql.Array;
import java.util.Arrays;

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 android.os.Bundle;
import android.os.StrictMode;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends ActionBarActivity {
EditText Number;
Button bn;
TextView source, destination, via;
String displayText;
String studentNo;
String str2array;
ArrayAdapter<string> list;

// private static String Result;
// private String TAG = "PGGURU";

private final String NAMESPACE = "http://tempuri.org/";
private final String METHOD_NAME = "Search_BusDetails";
private final String SOAP_ACTION = "http://tempuri.org/Search_BusDetails";// http://localhost:55134/WebSite2/Service.asmx/findContact
private final String URL = "http://10.0.2.2:55129/WebSite1/Service.asmx";

// private String ReadNumber;

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (android.os.Build.VERSION.SDK_INT > 9) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.permitAll().build();
StrictMode.setThreadPolicy(policy);
}

Number = (EditText) findViewById(R.id.BusNumber);
source = (TextView) findViewById(R.id.Source);
destination = (TextView) findViewById(R.id.Destination);
via = (TextView) findViewById(R.id.via);

bn = (Button) findViewById(R.id.Search);
bn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
call(studentNo);
studentNo = Number.getText().toString();
/*
* AsynchCall text=new AsynchCall(); text.execute();
*/
}
});
}

public void call(String studentNo) {

try {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo propertyInfo = new PropertyInfo();
propertyInfo.type = PropertyInfo.STRING_CLASS;
propertyInfo.name = "eid";

request.addProperty(propertyInfo, studentNo);

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;

envelope.setOutputSoapObject(request);

HttpTransportSE httpTransport = new HttpTransportSE(URL);
try {
httpTransport.call(SOAP_ACTION, envelope);
// SoapObject response = (SoapObject)envelope.getResponse();
// String source1=
// response.getProperty("getAlertsResult").toString();
Object response = envelope.getResult();




} catch (Exception ex) {
Log.i(ex.toString(), "thevalue");
via.setText(ex.toString()
+ " Or enter number is not Available!");
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
/*
* private class AsynchCall extends AsyncTask<string,> {
*
* @Override protected Void doInBackground(String... params) { // TODO
* Auto-generated method stub
*
* return null; }
*
* @Override protected void onPostExecute(Void result) {
* nr.setText(displayText); super.onPostExecute(result); }
*
*
* }
*/

}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900