import java.util.ArrayList;
import java.util.List;
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;
public class Cylexwebservice extends Activity {
private static final String SOAP_ACTION = "http://tempuri.org/
FetchCompanyData";
private static final String METHOD_NAME = "FetchCompanyData";
private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = "http://example.com/service.asmx";
TextView tv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv = (TextView)findViewById(R.id.txtCompName);
SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
Request.addProperty("companyname","MicroCrash");
Request.addProperty("country","United States");
Request.addProperty("zipcode","");
SoapSerializationEnvelope SoapEnv = new
SoapSerializationEnvelope(SoapEnvelope.VER11);
SoapEnv.dotNet = true;
SoapEnv.setOutputSoapObject(Request);
HttpTransportSE aht = new HttpTransportSE(URL);
try
{
aht.call(SOAP_ACTION, SoapEnv);
SoapObject resultString = (SoapObject)SoapEnv.getResponse();
SoapObject details =
(SoapObject)resultString.getProperty("diffgram");
List<CharSequence> list = new
ArrayList<CharSequence>(details.getPropertyCount());
int detailPropertycount = details.getPropertyCount();
for (int i = 0; i < detailPropertycount ; i++) {
Object property = details.getProperty(i);
if (property instanceof SoapObject) {
SoapObject compdetail = (SoapObject) property;
String table =
compdetail.getProperty("Table").toString();
int compPropCount = compdetail.getPropertyCount();
for(int j=0;j<compPropCount;j++)
{
Object CompProperties = compdetail.getProperty(j);
if(CompProperties instanceof SoapObject)
{
SoapObject CompInfo = (SoapObject)
CompProperties;
String information =
CompInfo.getProperty("COMPANY_NAME").toString();
String teleinformation =
CompInfo.getProperty("COMPANY_PHONE").toString();
String urlinformation =
CompInfo.getProperty("COMPANY_URL").toString();
list.add("\nResult:"+j+"\nCompany Name:" +
information
+ "\nTelephone:" +
Teleinformation
+ "\nAddress:" +
urlinformation);
}
}
}
}
tv.setText(list.toString());
}
catch(Exception err)
{
tv.setText("Some error occured!" + err.getMessage());
}
}
}
--
You received this message because you are subscribed to the Google Groups
"Android Discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/android-discuss?hl=en.