web service doesn’t respond with the expected value

im trying to consume an aspx web service from android.When i click on the button i dont get any response from the system.Can anyone figure out the simple mistake that im doing?my android code is as follows: package com.example.fp1_webservicedropdown; import java.util.ArrayList;import java.util.List; import org.ksoap2.SoapEnvelope;import org.ksoap2….

via Android Application Development » Search Results » ajax:

web service doesn’t respond with the expected value

im trying to consume an aspx web service from android.
When i click on the button i dont get any response from the system.
Can anyone figure out the simple mistake that im doing?
my android code is as follows:
package com.example.fp1_webservicedropdown;

import java.util.ArrayList;
import java.util.List;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;

import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity implements OnClickListener

private static final String SOAP_ACTION = “http://tempuri.org/add”;
private static final String METHOD_NAME = “add”;
private static final String NAMESPACE = “http://tempuri.org/”;
private static final String URL = “http://localhost:55084/mySimpleWS.asmx”;

private Spinner newSpinner;
private Button btn1;
private TextView tv2;

String tempVal;

@Override
protected void onCreate(Bundle savedInstanceState)

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

newSpinner = (Spinner) findViewById(R.id.spinner1);
btn1 = (Button) findViewById(R.id.button1);
btn1.setOnClickListener(this);

/*String list[] = “18-64646″, “18-8275″, “64-64646″, “69876-64646″,
“13-64646″, “PP-64646″, “123-64646″, “18-64646″, “18-8275″,
“64-64646″, “69876-64646″, “13-64646″, “PP-64646″, “123-64646″,
“18-8275″, “64-64646″, “69876-64646″, “13-64646″, “PP-64646″,
“123-64646″, “18-64646″, “18-8275″, “64-64646″, “18-64646″,
“18-8275″, “64-64646″, “69876-64646″, “13-64646″, “PP-64646″,
“123-64646″, “18-64646″, “18-8275″, “64-64646″, “69876-64646″,
“13-64646″, “PP-64646″, “123-64646″, “18-8275″, “64-64646″,
“69876-64646″, “13-64646″, “PP-64646″, “123-64646″, “18-64646″,
“18-8275″, “64-64646″;

// List list = new ArrayList();

ArrayAdapter dataAdapter = new ArrayAdapter(this,
android.R.layout.simple_spinner_item, list);
dataAdapter
.setDropDownViewResource(android.R.layout.simple_gallery_item);
newSpinner.setAdapter(dataAdapter);
*/
}

@Override
public boolean onCreateOptionsMenu(Menu menu)
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;

@Override
public void onClick(View arg0)

// TODO Auto-generated method stub
newSpinner = (Spinner) findViewById(R.id.spinner1);
tv2 = (TextView) findViewById(R.id.textView2);
/*tempVal = newSpinner.getSelectedItem().toString();
//tv2.setText(tempVal);

Context context = getApplicationContext();
CharSequence text = “You selected ” + tempVal
+ ” as the vehicle number!”;
int duration = Toast.LENGTH_SHORT;

Toast toast = Toast.makeText(context, text, duration);
toast.show();
*/

//—- web service access and data retrieval —-//

SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);

Request.addProperty(“add”, “1″);
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.dotNet = true;
soapEnvelope.setOutputSoapObject(Request);
AndroidHttpTransport aht = new AndroidHttpTransport(URL);

try

aht.call(SOAP_ACTION, soapEnvelope);
SoapPrimitive resultString = (SoapPrimitive) soapEnvelope.getResponse();
tv2.setText(resultString.toString());

catch (Exception e)
e.printStackTrace();

//————– —————-//

}

}also my web service code is as follows:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace mySimpleWS

///

/// Summary description for Service1
///

[WebService(Namespace = “http://tempuri.org/”)]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService

[WebMethod]
public int add(int a)

int c = 0;

c = a + 5;

return c;

}
}
any help is greatly appreciated.

For more info: web service doesn’t respond with the expected value

Android Application Development » Search Results » ajax

web service doesn’t respond with the expected value

Share this post:

Related Posts

Leave a Comment