I am very new Android Soap Web-services I have some knowledge on consuming soap web-services in Android using Ksoap2 for that I write the following Code :by using ksoap2.jar I got the namespace and method name from The WSDL File.
package com.soapwebservices.pack;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
public class SampleWSExampleActivity extends Activity {
private static final String TAG = null;
/** Called when the activity is first created. */
final String NAMESPACE = "urn:sap-com:document:sap:soap:functions:mc-style";
final String URL = "http://***************:8000/sap/bc/srt/wsdl/srvc_14DAE9C8D79F1EE196F1FC6C6518A345/wsdl11/allinone/ws_policy/document?sap-client=800&sap-user=********&sap-password=*******";
final String METHOD_NAME = "Z_GET_CUST_GEN";
final String SOAP_ACTION = "urn:sap-com:document:sap:soap:functions:mc-style/Z_GET_CUST_GEN";
// private static final String[] sampleACTV = new String[];
@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 androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
System.out.println("THE SOAP RESPONSE"+resultsRequestSOAP);
//ACTV.setHint("Received :" + resultsRequestSOAP.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
}
when i run this program i got the following Exception but in some examples i got the success please see once and let me know where i am doing the mistake
08-20 15:21:40.296: WARN/System.err(1668): org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <{http://schemas.xmlsoap.org/wsdl/}wsdl:definitions targetNamespace='urn:sap-com:document:sap:soap:functions:mc-style'>@1:686 in java.io.InputStreamReader@4052f658)
How can handle that exc
Maybe nothing is wrong with your code...
I solved my XMLPullParser exception after realizing that I was not pointing my client at my service. It expected to be able to use SOAP response and requests but was seeing wsdl. it was tricky to figure out. I'm not sure what your System.err(1668) is but here is what I suggest you do.
Download and attach the android-ksoap2 source code, so that you may step into the call (F5) to see while debugging where the error is raised in the ksoap2 package.
https://github.com/mosabua/ksoap2-android/downloads
and
Install and run the free SoapUI to test the webservice, and figure out exactly the correct Action, method, URL and namespace are, as it is most likely a problem with them if your code is ok. The first 2 mins of this intro video was all I needed to test my service.
Finally write a simple client in a different language - I found it easy to do in VB.NET express once I added a web reference to my project for the web-service. (That taught me with the help of SoapUI to make my wsdl WS-I compliant)
Good luck finding your solution.