Android :Problem with parameter passing(webservices) - android

I am new to web services and I got a problem with the response in the logcat. I am passing all my parameters to the server but the response is some what unreliable and I goggled a lot to find out the solution, but I cant.I am using Ksoap, WSDL in my webservices
The logcat message is this
06-17 14:20:31.168: VERBOSE/TAG(302): `RegisterUserResponse{RegisterUserResult=-1; }`
someone plz help me to solve this
private static final String SOAP_ACTION = "http://tempuri.org/RegisterUser";
private static final String METHOD_NAME = "RegisterUser";
private static final String NAMESPACE = "http://tempuri.org";
private static final String URL = "http://........";
private static final String TAG = "HELLO";
Thread t;
ProgressDialog dialog;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button signin = (Button) findViewById(R.id.regsubmitbtn);
signin.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
showDialog(0);
t = new Thread() {
public void run() {
register();
}
};
t.start();
}
});
}
#Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case 0: {
dialog = new ProgressDialog(this);
dialog.setMessage("Please wait while connecting...");
dialog.setIndeterminate(true);
dialog.setCancelable(true);
return dialog;
}
Button regmalebtn;
public void register() {
Log.v(TAG, "Trying to Login");
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
soapEnvelope.dotNet = true;
soapEnvelope.setOutputSoapObject(request);
// String response1 = request.getProperty(0).toString() ;
request.addProperty("fname", "raghav");
request.addProperty("lname", "raju");
request.addProperty("dateofbirth", "18-01-1985");
request.addProperty("email", "raghuraju90#yahoo.com");
request.addProperty("password", "1234");
//request.addProperty("password", repassword);
request.addProperty("mobno", "8553456260");
request.addProperty("latitude", "76");
request.addProperty("longitude", "82");
request.addProperty("device_id", "123456");
request.addProperty("gender", "male");
// request.addProperty("latitude',latitude);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
try {
androidHttpTransport.call(SOAP_ACTION, soapEnvelope);
androidHttpTransport
.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
SoapObject resultsRequestSOAP = (SoapObject) soapEnvelope.bodyIn;
// SoapObject result = (SoapObject) soapEnvelope.getResponse();
Log.v("TAG", String.valueOf(resultsRequestSOAP));
String resultData;
resultData = request.getProperty(0).toString();
}
return null;
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

That error is being generated by the server. You'll need to speak with the developer / owner of the server and get them to check their logs to determine why your transaction is failing.

Related

Async Task with multiple requests in android

I am using this asynctask Class to update two different tables on Sql Server so far this code works fine i'm interested in more better and sufficient code structure of this class specially in doinbackground() Is it okay to call multiple webservices methods in a single thread? can any one suggest me?
private class Update extends AsyncTask<Void, Void, Integer> {
private final int FAILED_INVALID_RESPONSE = 0;
private final int SUCCESS_GET_DATA = 1;
ProgressDialog progress;
private String _phoneno;
private String _ticket;
UpdateTicket(String phoneno,String ticket){
_phoneno=phoneno;
_ticket=ticket;
}
#Override
protected void onPreExecute() {
super.onPreExecute();
progress = ProgressDialog.show(XYZ.this, "",
"In Progress...", false);
}
#Override
protected Integer doInBackground(Void... params) {
method1(_phoneno);
return method2(_phoneno,_ticket);
}
#Override
protected void onPostExecute(Integer result) {
progress.dismiss();
switch (result) {
case FAILED_INVALID_RESPONSE:
Toast.makeText(XYZ.this,"Please Check your Internet Connection.",Toast.LENGTH_SHORT).show();
break;
case SUCCESS_GET_DATA:
Toast.makeText(XYZ.this, "Success!", Toast.LENGTH_SHORT).show();
break;
}
}
int method1(String phoneno,String tickets)
{
final String methodname = "firstmethod";
final String NAMESPACE ="http://tempuri.org/";
final String URL="www.sampleurl.com";
final String SOAP_ACTION="http://tempuri.org/firstmethod";
int success=0;
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
SoapObject request = new SoapObject(NAMESPACE, methodname);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
request.addProperty("phoneno", phoneno);
request.addProperty("tickets", tickets);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try{
androidHttpTransport.call(SOAP_ACTION,envelope);
SoapObject response = (SoapObject) envelope.bodyIn;
if(response!=null){
success=1;
}
}
catch (Exception e)
{
e.printStackTrace();
}
return success;
}
int method2(String Phone) {
final String methodname = "secondmethod";
final String NAMESPACE ="http://tempuri.org/";
final String URL="www.sampleurl.com";
final String SOAP_ACTION="http://tempuri.org/secondmethod";
int success=0;
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
SoapObject request = new SoapObject(NAMESPACE, methodname);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
request.addProperty("phoneno", phoneno);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try{
androidHttpTransport.call(SOAP_ACTION,envelope);
SoapObject response = (SoapObject) envelope.bodyIn;
if(response!=null){
success=1;
}
}
catch (Exception e)
{
e.printStackTrace();
}
return success;
}
}
AsyncTask should only be used for tasks/operations that take quite few seconds.
AsyncTasks are executed serially on a single background thread (from API 11). So long running worker can block others.
Check some other gotchas.
Take a look at HeandlerThread.

HttpTransport.call(SOAP_ACTION1, envelope) not working?

private static String SOAP_ACTION1 = "http://www.w3schools.com/webservices/FahrenheitToCelsius";
private static String SOAP_ACTION2 = "http://www.w3schools.com/webservices/CelsiusToFahrenheit";
private static String NAMESPACE = "http://www.w3schools.com/webservices/";
private static String METHOD_NAME1 = "FahrenheitToCelsius";
private static String METHOD_NAME2 = "CelsiusToFahrenheit";
private static String URL = "http://www.w3schools.com/webservices/tempconvert.asmx?WSDL";
Button btnFar,btnCel,btnClear;
EditText txtFar,txtCel;
int value;
SoapObject result;
My code look like below
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnFar = (Button)findViewById(R.id.btnFar);
btnCel = (Button)findViewById(R.id.btnCel);
btnClear = (Button)findViewById(R.id.btnClear);
txtFar = (EditText)findViewById(R.id.txtFar);
txtCel = (EditText)findViewById(R.id.txtCel);
btnFar.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick(View v)
{
value = Integer.parseInt(txtFar.getText().toString());
new soapFahrenheit().execute();
}
});
btnClear.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick(View v)
{
txtCel.setText("");
txtFar.setText("");
}
});
}
private class soapFahrenheit extends AsyncTask<String, Integer, String> {
protected void onPreExecute()
{
//
txtCel.setText(value);
}
#Override
protected String doInBackground(String... arg0){
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME1);
//Use this to add parameters
request.addProperty("Fahrenheit",value);
//Declare the version of the SOAP request
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.dotNet = true;
try {
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION1, envelope);
result = (SoapObject)envelope.bodyIn;
} catch (Exception e) {
e.printStackTrace();
}
return result.getProperty(0).toString();
}
protected void onPostExecute(SoapObject result)
{
if(result != null)
{
txtFar.setText(result.getProperty(0).toString());
}
else
{
Toast.makeText(getApplicationContext(), "No Response",Toast.LENGTH_LONG).show();
}
}
}
}
did i miss anything here? this is killing my days.... please help
You are making a network communication on the main UI thread which not allowed Android 4.0+.
So, you need to create a background thread to make the request to the server.
AsyncTask is what you should be using.
The problem with the ACTION String
http://www.w3schools.com/webservices/tempconvert.asmx?op=FahrenheitToCelsius
And xml form
POST /webservices/tempconvert.asmx HTTP/1.1
Host: www.w3schools.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.w3schools.com/webservices/FahrenheitToCelsius" // ACTION
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<FahrenheitToCelsius xmlns="http://www.w3schools.com/webservices/">
<Fahrenheit>string</Fahrenheit>
</FahrenheitToCelsius>
</soap:Body>
</soap:Envelope>
So the ACTION name should like
private static String SOAP_ACTION1 = "http://www.w3schools.com/webservices/FahrenheitToCelsius";
and
private static String SOAP_ACTION2 = "http://www.w3schools.com/webservices/CelsiusToFahrenheit";
Hope this will solve your problem.
And use dont't do network operation on UI Thread. Use AsynTask
EDIT:
private void doNetwork() {
SoapObject resultRequestSOAP = new SoapObject(NAMESPACE1, METHOD_NAME1);
PropertyInfo pi1 = new PropertyInfo();
pi1.setName("Fahrenheit");
pi1.setValue(""+value);// Say value= 10
pi1.setType(PropertyInfo.STRING_CLASS);
resultRequestSOAP.addProperty(pi1);
SoapSerializationEnvelope envp = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envp.dotNet = true;
try {
envp.setOutputSoapObject(resultRequestSOAP);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
androidHttpTransport.call(SOAP_ACTION1, envp);
SoapObject response = (SoapObject) envp.bodyIn;
System.out.println("response"+response.toString() + " "+response.getProperty(0).toString());
} catch (Exception e) {
}
}
OUTPUT:
FahrenheitToCelsiusResponse{FahrenheitToCelsiusResult=-12.2222222222222; }

Android:unable to get data from webservice using kSoap

hi in my app i am trying to check the username and password in database from webservice and if its true will show success message or failed message, but unable to show the status message
public class AndroidLoginExampleActivity extends Activity {
private final String NAMESPACE = "http://ws.userlogin.com";
private final String URL = "http://localhost:8080/Androidlogin/services/Login?wsdl";
private final String SOAP_ACTION = "http://ws.userlogin.com/authentication";
private final String METHOD_NAME = "authentication";
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button login = (Button) findViewById(R.id.btn_login);
login.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
loginAction();
}
});
}
#SuppressLint("NewApi") private void loginAction(){
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
EditText userName = (EditText) findViewById(R.id.tf_userName);
String user_Name = userName.getText().toString();
EditText userPassword = (EditText) findViewById(R.id.tf_password);
String user_Password = userPassword.getText().toString();
//Pass value for userName variable of the web service
PropertyInfo unameProp =new PropertyInfo();
unameProp.setName("userName");//Define the variable name in the web service method
unameProp.setValue(user_Name);//set value for userName variable
unameProp.setType(String.class);//Define the type of the variable
request.addProperty(unameProp);//Pass properties to the variable
//Pass value for Password variable of the web service
PropertyInfo passwordProp =new PropertyInfo();
passwordProp.setName("password");
passwordProp.setValue(user_Password);
passwordProp.setType(String.class);
request.addProperty(passwordProp);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try{
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
TextView result = (TextView) findViewById(R.id.tv_status);
result.setText(response.toString());
Log.d("resp:",response.toString() );
}
catch(Exception e){
}
}
below is my webservice call
public class Login {
public String authentication(String userName,String password){
String retrievedUserName = "";
String retrievedPassword = "";
String status = "";
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb","root","root");
PreparedStatement statement = con.prepareStatement("SELECT * FROM user WHERE username = '"+userName+"'");
ResultSet result = statement.executeQuery();
while(result.next()){
retrievedUserName = result.getString("username");
retrievedPassword = result.getString("password");
}
if(retrievedUserName.equals(userName)&&retrievedPassword.equals(password)){
status = "Success!";
}
else{
status = "Login fail!!!";
}
}
catch(Exception e){
e.printStackTrace();
}
return status;
}
}
not sure were iam doing wrong.Any help is appreciated.
You should do network realted operation on a thread. You can use a thread or AsyncTask.
Move your loginAction() inside a thread or inside doInbackground of AsyncTask.
Remember not to update ui from the back ground thread.
new TheTask().execute();
AsyncTask
public class TheTask extends AsyncTask <Void,Void,Void>
{
#Override
protected void onPreExecute() {
super.onPreExecute();
// display a dialog
}
#Override
protected Void doInBackground(Void... params) {
// your login authentcation
// remove updation of textview.
// do not update ui here
return null;
}
#Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
// dismiss the dialog
// update textview
}
}
AsyncTask docs
http://developer.android.com/reference/android/os/AsyncTask.html
Edit:
public class MainActivity extends Activity {
private final String NAMESPACE = "http://ws.userlogin.com";
private final String URL = "http://localhost:8080/Androidlogin/services/Login?wsdl";
private final String SOAP_ACTION = "http://ws.userlogin.com/authentication";
private final String METHOD_NAME = "authentication";
/** Called when the activity is first created. */
EditText ed1,ed2;
TextView tv;
String user_Name,user_Password;
SoapPrimitive response ;
ProgressDialog pd;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ed1 = (EditText) findViewById(R.id.editText1);
ed2 = (EditText) findViewById(R.id.editText2);
tv = (TextView) findViewById(R.id.textView1);
user_Name = ed1.getText().toString();
user_Password = ed2.getText().toString();
pd = new ProgressDialog(this);
Button login = (Button) findViewById(R.id.button1);
login.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
new TheTask().execute();
}
});
}
class TheTask extends AsyncTask<Void,Void,SoapPrimitive>
{
#Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
pd.show();
}
#Override
protected SoapPrimitive doInBackground(Void... params) {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo unameProp =new PropertyInfo();
unameProp.setName("userName");//Define the variable name in the web service method
unameProp.setValue(user_Name);//set value for userName variable
unameProp.setType(String.class);//Define the type of the variable
request.addProperty(unameProp);//Pass properties to the variable
PropertyInfo passwordProp =new PropertyInfo();
passwordProp.setName("password");
passwordProp.setValue(user_Password);
passwordProp.setType(String.class);
request.addProperty(passwordProp);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try{
androidHttpTransport.call(SOAP_ACTION, envelope);
response = (SoapPrimitive) envelope.bodyIn;
Log.i("Response",""+response);
// response = (SoapPrimitive)envelope.getResponse();
}
catch(Exception e){
}
return response;
}
#Override
protected void onPostExecute(SoapPrimitive result) {
super.onPostExecute(result);
pd.dismiss();
if(result!=null)
tv.setText(result.toString());
}
}
}
public static String ValidateSalesOfficerLogin(Context c, String userName,
String passWord) throws IOException, XmlPullParserException {
String METHOD_NAME = "ValidateSalesOfficerLogin";
String SOAP_ACTION = "http://tempuri.org/authentication/";
SOAP_ACTION = SOAP_ACTION + METHOD_NAME;
SoapObject request = new SoapObject(CommonVariable.NAMESPACE,
METHOD_NAME);
// Use this to add parameters
request.addProperty("Username", userName);
request.addProperty("Password", passWord);
// Declare the version of the SOAP request
return WebCalls.call(c, request, CommonVariable.NAMESPACE, METHOD_NAME,
SOAP_ACTION);
}
//////////////////////////////////////////////////////////////////////////////
public static String call(Context c,SoapObject request ,String NAMESPACE,String METHOD_NAME,String SOAP_ACTION) throws IOException, XmlPullParserException{
Log.i(WebCalls,"URL: "+ CommonVariable.URL);
Log.i(WebCalls,"Method Name: "+ METHOD_NAME);
Log.i(WebCalls,"Parameters: "+request.toString());
String SoapResult = null;
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.dotNet = true;
HttpTransportSE androidHttpTransport = new HttpTransportSE(CommonVariable.URL);
// this is the actual part that will call the webservice
androidHttpTransport.call(SOAP_ACTION, envelope);
// Get the SoapResult from the envelope body.
if (envelope.bodyIn instanceof SoapFault) {
SoapResult = ((SoapFault) envelope.bodyIn).faultstring;
} else {
SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
SoapResult = resultsRequestSOAP.getProperty(0).toString();
}
Log.i(WebCalls,"Response: "+ SoapResult);
return SoapResult;
}
call above method....
public static void Setusernamepassword(Context context, String user ,string pass)
throws JSONException, IOException, XmlPullParserException {
String Response = SoaplCalls.ValidateSalesOfficerLogin(context, user,pass);
Log.i("SetTokenId", Response);
}
/////////////////////////////////////////////////////////////////////////////////////
new Thread(new Runnable() {
#Override
public void run() {
try {
Setusernamepassword(viewCompetitor,user,pass);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
mHandler.post(new Runnable() {
#Override
public void run() {
}
});
}
}
}).start();
}

Android Soap Web service Error behind Proxy Server

I have written a program for communicating with a web service and get response value. But when i debug the programme i end with requestDump=null at the line androidHttpTransport.call(SOAP_ACTION, envelope); Can some one tell me the reason for the error and what can i do for this
public class WebService extends Activity {
private final String NAMESPACE = "http://tempuri.org/";
private final String URL = "http://www.w3schools.com/webservices/tempconvert.asmx";
private final String SOAP_ACTION = "http://tempuri.org/CelsiusToFahrenheit";
private final String METHOD_NAME = "CelsiusToFahrenheit";
String celsius;
Button b;
TextView tv;
EditText et;
String res,resultval;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_service);
et=(EditText)findViewById(R.id.editText1);
tv=(TextView)findViewById(R.id.Result);
b=(Button)findViewById(R.id.button1);
b.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
//String result=getFarenheit(et.getText().toString());
//tv.setText(result+"°F");
new service().execute();
}
});
}
private class service extends AsyncTask<Void, Void, String>{
#Override
protected String doInBackground(Void... arg0) {
celsius=et.getText().toString();
SoapObject request= new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo celsuiusPI= new PropertyInfo();
celsuiusPI.setName("Celsius");
celsuiusPI.setValue(celsius);
celsuiusPI.setType(String.class);
request.addProperty("XMLMarks",celsuiusPI);
SoapSerializationEnvelope envelope=new SoapSerializationEnvelope (SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.implicitTypes = true;
envelope.enc = SoapSerializationEnvelope.ENC2003;
envelope.xsd = SoapEnvelope.XSD;
envelope.xsi = SoapEnvelope.XSI;
envelope.setOutputSoapObject(request);
envelope.setAddAdornments(false);
SoapPrimitive response;
HttpTransportSE androidHttpTransport=new HttpTransportSE(URL);
try{
androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
androidHttpTransport.debug = true;
androidHttpTransport.call(SOAP_ACTION, envelope);
String dump= androidHttpTransport.requestDump.toString();
response=(SoapPrimitive)envelope.getResponse();
Toast.makeText(WebService.this, response.toString(), 20).show();
Log.i("WebService output", response.toString());
System.out.println("WebService Response"+response.toString());
Object res= response.toString();
resultval=(String) res;
}
catch(Exception e){
e.printStackTrace();
}
return res;
}
protected void onPostExecute(String h){
String result=h;
tv.setText(result+"°F");
}
}
}
Just replace your service AsyncTask with this new one and see result:
code:
private class service extends AsyncTask<Void, Void, String> {
#Override
protected String doInBackground(Void... arg0) {
System.out.println("In DoIn Background");
// Initialize soap request + add parameters
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
// Use this to add parameters
request.addProperty("Celsius", txtCel.getText().toString());
// Declare the version of the SOAP request
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.dotNet = true;
try {
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
// this is the actual part that will call the webservice
androidHttpTransport.call(SOAP_ACTION, envelope);
// Get the SoapResult from the envelope body.
SoapObject result = (SoapObject) envelope.bodyIn;
if (result != null) {
// Get the first property and change the label text
// txtFar.setText(result.getProperty(0).toString());
res = result.getProperty(0).toString();
} else {
Toast.makeText(getApplicationContext(), "No Response",
Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
e.printStackTrace();
}
return res;
}
protected void onPostExecute(String h) {
String result = h;
tv.setText(result + "°F");
}
}

Logfile showing empty fields in the server side

i got a problem with my web services code. with the code I am passing the user credentials to server, but at the server side log file showing empty fields I cant understand the problem as I am new to webservices. I am using ksoap ,wsdl for my webservices
Any help would be greatly appreciated...
this is the code
private static final String SOAP_ACTION = "http://tempuri.org/RegisterUser";
private static final String METHOD_NAME = "RegisterUser";
private static final String NAMESPACE = "http://tempuri.org";
private static final String URL = "http://........";
private static final String TAG = "HELLO";
Thread t;
ProgressDialog dialog;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button register = (Button) findViewById(R.id.regsubmitbtn);
register.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
showDialog(0);
t = new Thread() {
public void run() {
register();
}
};
t.start();
}
});
}
#Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case 0: {
dialog = new ProgressDialog(this);
dialog.setMessage("Please wait while connecting...");
dialog.setIndeterminate(true);
dialog.setCancelable(true);
return dialog;
}
Button regmalebtn;
public void register() {
Log.v(TAG, "Trying to Login");
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
soapEnvelope.dotNet = true;
soapEnvelope.setOutputSoapObject(request);
// String response1 = request.getProperty(0).toString() ;
request.addProperty("fname", "raghav");
request.addProperty("lname", "raju");
request.addProperty("dateofbirth", "18-01-1985");
request.addProperty("email", "raghuraju90#yahoo.com");
request.addProperty("password", "1234");
//request.addProperty("password", repassword);
request.addProperty("mobno", "8553456260");
request.addProperty("latitude", "76");
request.addProperty("longitude", "82");
request.addProperty("device_id", "123456");
request.addProperty("gender", "male");
// request.addProperty("latitude',latitude);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
try {
androidHttpTransport.call(SOAP_ACTION, soapEnvelope);
androidHttpTransport
.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
SoapObject resultsRequestSOAP = (SoapObject) soapEnvelope.bodyIn;
// SoapObject result = (SoapObject) soapEnvelope.getResponse();
Log.v("TAG", String.valueOf(resultsRequestSOAP));
String resultData;
resultData = request.getProperty(0).toString();
}
return null;
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
For this you should get a copy of Charles - http://www.charlesproxy.com/
You can configure it to act as a reverse proxy and then if you aim your web service code at the reverse proxy you'll be able to inspect the traffic flowing from your phone to the server. I've outlined the whole process in another thread.
Android to Drupal cookie transfer Q2
If you need help let me know.

Categories

Resources