View Single Post
Old 08-31-2010, 10:00 AM   #7 (permalink)
romah
Knows Where the Search Button Is
 
Join Date: Jun 2010
Model: 8530
PIN: N/A
Carrier: Sprint
Posts: 48
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Also please see this if you want to use KSOAP
Code:
//passing strings and returns EmployeeResponse object
FieldChangeListener employeeListener = new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
String serviceUrl = "http : //servername/service1.asmx";
String serviceNamespace = "http : //tempuri.org/";
String soapAction = "http : //tempuri.org/GetEmployeeDetail";

SoapObject rpc = new SoapObject(serviceNamespace,"GetEmployeeDetail");

rpc.addProperty("EmployeeID", "123");
rpc.addProperty("EmployeeName", "MyName");

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = rpc;
envelope.dotNet = true; 
envelope.encodingStyle = SoapSerializationEnvelope.XSD;
envelope.addMapping("http : //tempuri.org/encodedTypes",
"EmployeeResponse", new EmployeeResponse().getClass());

envelope.setOutputSoapObject(rpc);

HttpTransport ht = new HttpTransport(serviceUrl);
ht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
ht.debug = true;

try {
ht.call(soapAction, envelope);
EmployeeResponse myObj = (EmployeeResponse) envelope.getResponse();
add(new RichTextField("ID: " + myObj.EmpID + "\n" + "Name: "+ myObj.EmpName + "\n" + "Phone: " + myObj.Phone + "\n"+ "Address: " + myObj.Address));
} 
catch (Exception ex) {
String msg = ex.toString();
System.out.println(msg);
add(new RichTextField("Error Message: " + msg));
}
}
};

Last edited by romah : 08-31-2010 at 10:02 AM.
Offline   Reply With Quote