0

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.

user1796222
  • 275
  • 2
  • 4
  • 10
  • you have a class cast exception at RetailerActivity.java line 36. Please post the code you used and also specify/mark the line no.36 – Abhishek Nandi Nov 20 '12 at 05:04
  • i have updated my question with code.please check it and give me solution for this – user1796222 Nov 20 '12 at 05:09
  • i have to change SoapPrimitive response = (SoapPrimitive)envelope.getResponse(); to SoapObject response = (SoapObject)envelope.getResponse(); means am getting anyType{} on my emulator.nothing error is displayed on my console window.please give me solution for this – user1796222 Nov 20 '12 at 05:11
  • Log your response. and post it – Abhishek Nandi Nov 20 '12 at 05:16
  • i have to put this url private static final String URL = "http://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 = "http://87.76.29.180:8080/TestPrompts/services/Fetch?wsdl" only am getting following error.this wsdl file run on tomcat server at remotely. – user1796222 Nov 20 '12 at 05:21
  • am getting the response like :11-19 20:08:57.251: E/Error :(6493): Error on soapPrimitiveData() org.ksoap2.serialization.SoapObject – user1796222 Nov 20 '12 at 05:23

3 Answers3

0

I believe you are not getting a primitive type. Try this:

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

See: Trying to build a correct SOAP Request

Community
  • 1
  • 1
Abhishek Nandi
  • 4,265
  • 1
  • 30
  • 43
  • i have to change SoapPrimitive response = (SoapPrimitive)envelope.getResponse(); to SoapObject response = (SoapObject)envelope.getResponse(); means am getting anyType{} on my emulator.nothing error is displayed on my console window.please give me solution for this – user1796222 Nov 20 '12 at 05:17
  • whats your response, can you post it as well. Just log the response. that will help debug this issue – Abhishek Nandi Nov 20 '12 at 05:19
  • am getting the response like :11-19 20:08:57.251: E/Error :(6493): Error on soapPrimitiveData() org.ksoap2.serialization.SoapObject – user1796222 Nov 20 '12 at 05:22
  • i have to use below code for getting response from server: Log.e("Error : " , "Error on soapPrimitiveData() " + e.getMessage()); it is correct only.here only am getting above comment error – user1796222 Nov 20 '12 at 05:38
  • `ht.call(SOAP_ACTION, envelope);Log.d("Response", "Response: "+ht.responseDump);`. You are logging the exception message and not the server response. Also it is better to use `Log.e("Error", "Error on soapPrimitiveData() ", e);`. That way you get the entire stack trace – Abhishek Nandi Nov 20 '12 at 05:45
  • i have changed my code like Log.e("Error", "Error on soapPrimitiveData() ", e);Here am getting anyType{} message is displayed on my android emulator.no error is displayed on my console window. – user1796222 Nov 20 '12 at 08:55
0

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.

user1796222
  • 275
  • 2
  • 4
  • 10
0

Try to use AndroidHttpTransportSE in place of HttpTransportSE and add this statement after creating envelop. envelope.dotNet=true;

For better result look for this Tutorial

Community
  • 1
  • 1
Pankaj Kumar
  • 93
  • 1
  • 1
  • 5