Search code examples
javaandroidapachetomcatandroid-ksoap2

unable to access my WSDL file from tomcat server in android


I have to develop one android application.The app is performs retrieve data from mysql database and display on android emulator and android device.

First i have to setup tomcat server at localhost and run these wsdl file on localhost means am getting the retrieve data is successfully displayed on both emulator and android device.

Also i have to setup tomcat server on remotely.here i have upload my war file and get the wsdl file.now i have to put these wsdl URL means am getting blank screen on both my emulator and android device.

My console window shows following error:

11-19 19:43:26.331: W/System.err(6323): java.lang.ClassCastException: org.ksoap2.serialization.SoapObject
11-19 19:43:26.341: W/System.err(6323):     at com.retailer.client.RetailerActivity.onCreate(RetailerActivity.java:36)
11-19 19:43:26.341: W/System.err(6323):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-19 19:43:26.341: W/System.err(6323):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
11-19 19:43:26.341: W/System.err(6323):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-19 19:43:26.341: W/System.err(6323):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-19 19:43:26.341: W/System.err(6323):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-19 19:43:26.341: W/System.err(6323):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-19 19:43:26.341: W/System.err(6323):     at android.os.Looper.loop(Looper.java:123)
11-19 19:43:26.341: W/System.err(6323):     at android.app.ActivityThread.main(ActivityThread.java:4627)
11-19 19:43:26.341: W/System.err(6323):     at java.lang.reflect.Method.invokeNative(Native Method)
11-19 19:43:26.341: W/System.err(6323):     at java.lang.reflect.Method.invoke(Method.java:521)
11-19 19:43:26.341: W/System.err(6323):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-19 19:43:26.341: W/System.err(6323):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-19 19:43:26.341: W/System.err(6323):     at dalvik.system.NativeStart.main(Native Method)

How can i resolve this error.please help me.

This is my code:

    public class RetailerActivity extends Activity {
private static final String SOAP_ACTION = "http://ws.testprops.com/customerData";
private static final String METHOD_NAME = "customerData";
private static final String NAMESPACE = "http://ws.testprops.com";
   //private static final String URL = "http://10.0.0.133:8089/TestPrompts/services/Fetch?wsdl";
private static final String URL = "http://87.76.29.180:8080/TestPrompts/services/Fetch?wsdl";
/*
private static final String SOAP_ACTION = "http://xcart.com/customerData";
private static final String METHOD_NAME = "customerData";
private static final String NAMESPACE = "http://xcart.com";
private static final String URL = "http://10.0.0.133:8089/XcartLogin/services/Fetch?wsdl";*/

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.setOutputSoapObject(request);
    HttpTransportSE ht = new HttpTransportSE(URL);
    try {
        ht.call(SOAP_ACTION, envelope);
        SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
        SoapPrimitive s = response;
        String str = s.toString();
        String resultArr[] = str.split("&");//Result string will split & store in an array 
        TextView tv = new TextView(this);
        for(int i = 0; i<resultArr.length;i++){ 
        tv.append(resultArr[i]+"\n\n"); 
       }
        setContentView(tv);
} catch (Exception e) {
    //Log.e("Error : " , "Error on soapPrimitiveData() " + e.getMessage());
        e.printStackTrace();
}
    }
}

this is my 36th line:

 SoapPrimitive response = (SoapPrimitive)envelope.getResponse();

i have to put this url

private static final String URL = "10.0.0.133:8089/TestPrompts/services/Fetch?wsdl";

means am getting retrieve data.this wsdl file run on tomcat server at localhost.

but i have to put these url means

private static final String URL = "87.76.29.180:8080/TestPrompts/services/Fetch?wsdl";

this time only am getting above error.this wsdl file run on tomcat server at remotely.


Solution

  • I got the solution for this.Because my database have static permission only..I have to give permission for access database global means it is worked well.