How to call a WCF service using ksoap2 on android?

finally I got it to work because the namespace missed a “https://stackoverflow.com/” in the end , following is my code package cn.qing.ksop2test; import java.io.Writer; import org.ksoap2.*; import org.ksoap2.serialization.*; import org.ksoap2.transport.*; import org.xmlpull.v1.XmlSerializer; import android.app.Activity; import android.os.Bundle; import android.util.Xml; import android.widget.TextView; public class ksop2test extends Activity { /** Called when the activity is first created. */ … Read more

Parsing ksoap2 response

For example your Response: anyType { FOO_DEALS=anyType { CATEGORY_LIST=anyType { CATEGORY=Books; CATEGORY_URL=books_chennai; CATEGORY_ICON=http://deals.foo.com/common/images/books.png; CATEGORY_COUNT=1045; TYPE=1; SUPERTAG=Books; }; CATEGORY_LIST=anyType { CATEGORY=Cameras; CATEGORY_URL=cameras_chennai; CATEGORY_ICON=http://deals.foo.com/common/images/cameras.png; CATEGORY_COUNT=152; SUPERTAG=Cameras; TYPE=1; }; }; } For requesting and parsing do like this: SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); // Add the input required by web service request.addProperty(“city”,”chennai”); request.addProperty(“key”,”10000″); SoapSerializationEnvelope envelope =new SoapSerializationEnvelope(SoapEnvelope.VER11); … Read more

KSOAP 2 Android with HTTPS

Checking again this problem, I’ve discovered a more clean solution for me. No KSOAP2 files modification needed. In your project, link the ksoap2-android-assembly-3.0.0-jar, with no modifications. Next, create a file named SSLConnection.java with this code: package com.example.mypackage; import android.util.Log; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLSession; import javax.net.ssl.TrustManager; import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; … Read more

how to set soap Header using ksoap2 – android

I did that this way: import org.kxml2.kdom.Element; then while preparing envelope soapEnvelope.headerOut = new Element[1]; soapEnvelope.headerOut[0] = buildAuthHeader(); // …send request… with private Element buildAuthHeader() { Element h = new Element().createElement(NAMESPACE, “AuthHeader”); Element username = new Element().createElement(NAMESPACE, “user”); username.addChild(Node.TEXT, USERNAME); h.addChild(Node.ELEMENT, username); Element pass = new Element().createElement(NAMESPACE, “pass”); pass.addChild(Node.TEXT, PASSWORD); h.addChild(Node.ELEMENT, pass); return h; } … Read more

ksoap2 org.xmlpull.v1.xmlpullparserexception expected start_tag error

Below solution is tested and used for WCF Web Services If you are getting this error org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <html> @1:7 in java.io.InputStreamReader@41afb3f0)” Then the possible chances are that your code is not able to access the web service as it has not been provided with correct values of METHOD_NAME=””; NAMESPACE =””; SOAP_ACTION … Read more