problem in sending & receiving string[] from .netwebserv

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

problem in sending & receiving string[] from .netwebserv

Postby sudhakar » Fri Feb 20, 2009 1:58 pm

hi all,

i have tried with sending and recieving a string from .net webservice and it is workingfine. Now iam trying to send a string array and trying to recieve a string array here i am getting problem while recieving.

here i am appending code below. pls help me..

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

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


public class CommSer extends Activity {
/** Called when the activity is first created. */
private static final String SOAP_ACTION = "http://tempuri.org/HelloAndroid";
private static final String METHOD_NAME = "HelloAndroid";

private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = "http://192.168.1.66/Applications/WebSite10/Service.asmx";
private Object resultRequestSOAP = null;
String[] sendArr=new String[5];
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
setContentView(R.layout.main);

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
int len = sendArr.length;
for (int i = 0; i < len; i++)
{
sendArr[i] = i + "";
}


request.addProperty("strarr",sendArr);


Toast.makeText(getBaseContext(), "1",
Toast.LENGTH_SHORT).show();

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.dotNet=true;
Toast.makeText(getBaseContext(), "2",
Toast.LENGTH_LONG).show();

HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try
{
androidHttpTransport.call(SOAP_ACTION, envelope);
resultRequestSOAP = envelope.getResponse();

String[] resArr = (String[]) resultRequestSOAP;

for (int i = 0; i < resArr.length; i++)
{
Toast.makeText(getBaseContext(), resArr[i].toString(),
Toast.LENGTH_LONG).show();
}
Toast.makeText(getBaseContext(), resultRequestSOAP.toString(),
Toast.LENGTH_LONG).show();

}
catch (Exception aE)
{
//aE.printStackTrace ();;
Toast.makeText(getBaseContext(), aE.toString(),
Toast.LENGTH_LONG).show();
}
}

}
sudhakar
Freshman
Freshman
 
Posts: 3
Joined: Thu Feb 19, 2009 7:45 am

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests