i am self-leaner to android.Right now i am consuming web service in android eclipse by the method SOAP.So i have created two pages.The first page consists of an edittext and a button and the second page consists of only one textbox.I am creating exactly like this webservice GetBibleWordsbyKeyWord in android eclipse.
Here my need is to get the input from the user by edittext box on page one and display appropriate texts on second page’s textbox exactly what the above web service is going to invoke(display)according to the user’s input.These things must want to be happen when clicking the button from the page one.
NOTE :- I have tried it.Its getting run.But its only showing a blank pages on page two
What to do to achieve this concept?
Please find my code for reference
Webservice Backend Class [DYNAMIC PROJECT]
public class GetStudentInformation {
public String GetStudentInformation(String str){
return(str);
}
}
Android java class page1
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button next = (Button) findViewById(R.id.btn);
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), Web_concept.class);
startActivityForResult(myIntent, 0);
}
});
}
}
Android java class page2
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main1);
try
{
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
EditText num1 = (EditText) findViewById(R.id.editT);
request.addProperty("str", Integer.valueOf(num1.getText().toString()));
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION,envelope);
Object result = envelope.getResponse();
System.out.println("Result : " + result.toString());
((TextView) findViewById (R.id.textView1)).setText(result.toString());
}
catch (Exception E) {
E.printStackTrace();
}
}
}
Thanks for any help!
First thing change your input to web service as define in web service method
i.e change the line
request.addProperty("str", Integer.valueOf(num1.getText().toString()));
to
request.addProperty("str", num1.getText().toString());
as you define
stras String in yourwebmethodand second thing change
Object result = envelope.getResponse();
to
Object result = envelope.bodyIn;
and please check on Internet how to access
textViewof second page in first page.I am not sure about it.may be it is not possible.