Unable to get response from a web service using KSoap

Put your problem here if it does not fit any of the other categories.

Unable to get response from a web service using KSoap

Postby shaamu786 » Wed Apr 20, 2011 2:07 pm

Hi All,

I am using Ksoap2 api for integrating the web services. The web services that require no input from user, are working fine.

But in case of input it is giving SoapFault Exception.

Please suggest me. i am sharing the code here and details....

im given a envelop string for this method

Article:
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:def="http://DefaultNamespace">
<soapenv:Header/>
<soapenv:Body>
<def:article soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<articleID xsi:type="xsd:double">$ARTICLEID</articleID>
</def:article>
</soapenv:Body>
</soapenv:Envelope>


Syntax: [ Download ] [ Hide ]
  1. private String getNewsDetails() { 
  2.  
  3. String URL = "http://heinrich.house.gov/common/site/mobile.cfc?WSDL"; 
  4. String NAMESPACE = "http://DefaultNamespace/"; 
  5.  
  6. String METHOD_NAME = "article"; 
  7. String SOAP_ACTION = "http://DefaultNamespace/article"; 
  8.  
  9. SoapObject request = new SoapObject(NAMESPACE,METHOD_NAME); 
  10.  
  11. request.addProperty("articleID", "590"); //590 or 592 etc... for test-case 
  12.  
  13. SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
  14. // envelope.dotNet = true; 
  15. envelope.setOutputSoapObject(request); 
  16. AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL); 
  17.  
  18. try { 
  19. androidHttpTransport.call(SOAP_ACTION,envelope); 
  20. resultsRequestSOAP = (SoapObject) envelope.bodyIn; 
  21.  
  22. Log.e("Response", "getNewsDetails..." + resultsRequestSOAP); 
  23. return resultsRequestSOAP.toString(); 
  24. } catch (IOException e) { 
  25. Log.e("TAG","IOException...."+e); 
  26. new AlertDialog.Builder(this).setTitle("Error") 
  27. .setMessage(e.getMessage()).setPositiveButton("OK", null) 
  28. .show(); 
  29. } catch (XmlPullParserException e) { 
  30. Log.e("TAG","XmlPullParserException...."+e); 
  31. new AlertDialog.Builder(this).setTitle("Error") 
  32. .setMessage(e.getMessage()).setPositiveButton("OK", null) 
  33. .show(); 
  34. return null; 






here is the response....

04-20 18:32:24.245: ERROR/AndroidRuntime(940): FATAL EXCEPTION: main
04-20 18:32:24.245: ERROR/AndroidRuntime(940): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.demo.view/com.demo.view.Demo}: java.lang.ClassCastException: org.ksoap2.SoapFault
04-20 18:32:24.245: ERROR/AndroidRuntime(940): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1622)
04-20 18:32:24.245: ERROR/AndroidRuntime(940): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)
04-20 18:32:24.245: ERROR/AndroidRuntime(940): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-20 18:32:24.245: ERROR/AndroidRuntime(940): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928)
04-20 18:32:24.245: ERROR/AndroidRuntime(940): at android.os.Handler.dispatchMessage(Handler.java:99)
04-20 18:32:24.245: ERROR/AndroidRuntime(940): at android.os.Looper.loop(Looper.java:123)
04-20 18:32:24.245: ERROR/AndroidRuntime(940): at android.app.ActivityThread.main(ActivityThread.java:3647)
04-20 18:32:24.245: ERROR/AndroidRuntime(940): at java.lang.reflect.Method.invokeNative(Native Method)
04-20 18:32:24.245: ERROR/AndroidRuntime(940): at java.lang.reflect.Method.invoke(Method.java:507)
04-20 18:32:24.245: ERROR/AndroidRuntime(940): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-20 18:32:24.245: ERROR/AndroidRuntime(940): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-20 18:32:24.245: ERROR/AndroidRuntime(940): at dalvik.system.NativeStart.main(Native Method)
04-20 18:32:24.245: ERROR/AndroidRuntime(940): Caused by: java.lang.ClassCastException: org.ksoap2.SoapFault
04-20 18:32:24.245: ERROR/AndroidRuntime(940): at com.demo.view.Demo.getNewsDetails(Demo.java:141)
04-20 18:32:24.245: ERROR/AndroidRuntime(940): at com.demo.view.Demo.onCreate(Demo.java:36)
04-20 18:32:24.245: ERROR/AndroidRuntime(940): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-20 18:32:24.245: ERROR/AndroidRuntime(940): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1586)
04-20 18:32:24.245: ERROR/AndroidRuntime(940): ... 11 more
xgw
shaamu786
Junior Developer
Junior Developer
 
Posts: 16
Joined: Tue Sep 01, 2009 7:17 am
Location: Delhi

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: MSNbot Media and 29 guests