Problem while calling the web services in android.
Problem while calling the web services in android.
To call web services in android I have done the following steps
1. Wrote the web service class in java and stored in apache axis. (in .jws format)
public class ADD2No
{
public int add(int a,int b)
{
return (a+b);
}
public int sub(int c,int d)
{
return (c-d);
}
}
2. Then is have tested the web service on web browser.
http://192.168.1.41:8081/axis/
I have got.
There is a Web Service here
Click to see the WSDL
in browser.
3. then I implement the service using core java and Ksoap2 library. Its working fine.
4. But I got error when I call the web service via android.
5. This is my code.
package com.example.SamWebService;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapO
import org.ksoap2.serialization.SoapS
import org.ksoap2.transport.AndroidHt
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class WebServiceInAndroid extends Activity
{
/** Called when the activity is first created. */
/*
private static final String SOAP_ACTION = "HelloYou";
private static final String METHOD_NAME = "getHello";
private static final String NAMESPACE = "urn:HelloYou";
private static final String URL = "http://localhost/lab/service.
*/
private static final String SOAP_ACTION = "ADD2No";
private static final String METHOD_NAME = "add";
private static final String NAMESPACE = "urn:ADD2No";
private static final String URL = "http://elcserver:8081/axis/AD
//private Object resultsRequestSOAP = null;
@Override
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
TextView tv = (TextView) findViewById(R.id.txt1);
setContentView(R.layout.main);
try
{
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("a", 3);
request.addProperty("b", 4);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(Soap
//envelope.dotNet = true;
envelope.setOutputSoapObject(
AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
try
{
androidHttpTransport.call(SOA
//Parse Response
SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
//String xy = resultsRequestSOAP.getProperty
tv.setText("Ganzes Rückagbeobjekt:\n"+resultsReq
}
catch (Exception e)
{
e.printStackTrace();
}
}
catch(Exception e)
{
tv.setText("Error : " + e.getMessage());
}
}
}
6. I have tried lot of methods still I am getting the error.
“Your application has been stopped unexpectedly”
7. my application’s manifest file is
<?xml version="1.0" encoding="utf-8"?>
8. So give me solutions to overcome this problem and how to define the SOAP_NAME, METHOD_NAME, NAMESPACE and URL what they meant really.
9. Give me the step by step procedure to call apache axis web services from android.
New tutorials from Helloandroid
Recent Apps
Android on Twitter
-
@lendzEra (ledz motin)
BaconReader gets major update, adds Android Beam support, scrollable widget and more http://t.co/aTXFOvQb #android
6 min 28 sec ago -
@grenhall (Mattias Grenhall)RT @iphonecruncher2012HP finally caves and offers up TouchPad Kernel Source http://t.co/HwddIG75 #android #googleandroid #android #apps
6 min 31 sec ago -
@lendzEra (ledz motin)
Sony Tablet P started life as a wallet, almost ran Windows http://t.co/qgi6Nrrs #android
6 min 31 sec ago -
@onebadcarr2 (chris)I've just received an achievement: Quick https://t.co/GfeDIsJo #Android #Androidgames
6 min 32 sec ago -
@darren3131 (darren)I've just received an achievement: Logistician https://t.co/Dn9r87yG #Android #Androidgames
6 min 34 sec ago
Poll
Useful resources
Android Development Projects
- Android App wanted immediately by JoePublic
- LIST DATA PROJ by nhammoud
- Nonpublic project #1433932 by subpariq
- Alarm Android Application Design by globalheed
- Simple Album App for Android by ayfonfan
- iOS and Android photo manipulation 'Morph App' by whatwedomedia
- Onsite Software Engineers in Germany by sudhirshree
- Augmented reality by merder99
- Nonpublic project #1433560 by vobla73
- Mobile app coder needed for quick, simple app by Ergometrix



it is sometimes world of hard to Pandora in a world of adults Pandora Bracelets