How to call a .NET Webservice from Android using KSOAP2? -


I have a problem when calling a webservice. I have a .NET Web service on the server, and I have a KSOAP2 Ksoap2-j2se-full-2.1.2). I got a runtime exception such as "org.ksoap2.serialization.SoapPrimitive" while running the program. What should I do?

This is my code.

  Package project. Ksoap2sample; Import org.ksoap2.SoapEnvelope; Import org.ksoap2.serialization.SoapObject; Import org.ksoap2.serialization.SoapSerializationEnvelope; Import org.ksoap2.transport.HttpTransportSE; Import android.app. *; Import android.os. *; Import android.widget.TextView; Public class ksoap2sample enhances activity {/ ** is called when activity first created. * / Personal static final string SOAP_ACTION = "http://tempuri.org/HelloWorld"; Private stable final string METHOD_NAME = "HelloWald"; Personal Static Last String NAMESPACE = "http://tempuri.org/"; Private Static Last String URL = "http://192.168.1.19/TestWeb/WebService.asmx"; TextView TV; Override public null on @reate (bundle saved instainstate) {super.naught (savedinstenstate); SetContentView (R.layout.main); TV = (TextView) findViewById (R.id.text1); {Try SoapObject Request = New Soap Object (NAMESPACE, METHOD_NAME); //request.addProperty("prop1 "," myprop "); SoapSerializationEnvelope envelope = new soapfication enfeef (sopenalphae envelope.dotNet true =; envelope.setOutputSoapObject (request); http transports s android htmltsport = new html transportse (url); androidhttpTransport.call (SOAP_ACTION, envelope); object result = (object) Envelopegateresons (); string [] result = (string []) result; tv.setText ("" + result [0]);} hold (exception e) {tv.setText (e.getMessage ());} }}}  

this Very simple you are getting the result in an object which is a primitive one.

Your code:

  object result = ( Object) EnvelopeGetresports ();  

Correct code:

  SOAPOBact result = (SOAP object) envelope.Getresons (); // Get data String result for data = result .getProperty (0) .toString (); // is the first object of the data  

I think it definitely wants to work E.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -