Reputation: 1
My call of web service is ok with android 4.0.3 but it is Ko with 2.2 version. It's a SOAP web service JBOSS 4.2.2. use ksoap2-android-assembly-2.6.0
I have an exception:
unexpected type (position:END_DOCUMENT null@1:0 in java.io.InputStreamReader@44f36cb0)
the code:
private static final String METHOD_NAME_findBeneficiaireLight = "findBeneficiaireLight";
private static final String NAMESPACE = "http://service.android.interiale.fr/";
private static final String URL = "http://10.0.2.2:8090/mgpatInternet-mgpatInternetEJB/AdherentService";
public BeneficiaireLight getBeneficiaire(String user_id, String password, SharedPreferences settings)
throws AuthentificationFailureException, WebConnectionException {
BeneficiaireLight results = null;
SoapObject request = new SoapObject(NAMESPACE,
METHOD_NAME_findBeneficiaireLight);
request.addProperty("arg0", user_id);
SoapSerializationEnvelope soapenvelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
soapenvelope.setOutputSoapObject(request);
soapenvelope.addMapping(NAMESPACE,
BeneficiaireLight.BeneficiaireLight_CLASS.getSimpleName(),
BeneficiaireLight.BeneficiaireLight_CLASS);
HttpTransportSE httptransport = new HttpTransportSE(URL);
httptransport.debug = true;
List<HeaderProperty> headers = new ArrayList<HeaderProperty>();
headers.add(new HeaderProperty("Authorization", "Basic "
+ Base64.encodeToString(
(user_id.toLowerCase() + ":" + password).getBytes(),
Base64.DEFAULT)));
try {
httptransport.call(NAMESPACE + METHOD_NAME_findBeneficiaireLight,
soapenvelope, headers);
Object res = (Object)soapenvelope.getResponse();
if (res instanceof SoapObject) {
results = new BeneficiaireLight((SoapObject) res);
}
} catch (SocketException ex) {
Log.e("Error : ", "Error on getBeneficiaire() " + ex.getMessage());
throw new WebConnectionException("service " + NAMESPACE
+ METHOD_NAME_findBeneficiaireLight + " KO", ex);
} catch (Exception e) {
Log.e("Error : ", "Error on getBeneficiaire() " + e.getMessage());
throw new AuthentificationFailureException();
}
return results;
Upvotes: 0
Views: 1393
Reputation: 29912
Might be a http transport or timing related issue. Try implementing a retry .. my call sometimes succeed at second hit.. and normally it should just work with both. My codebase works from 1.6 up.
Upvotes: 0
Reputation:
check your following code
Object res = (Object)soapenvelope.getResponse();
if (res instanceof SoapObject) {
results = new BeneficiaireLight((SoapObject) res);
}
when there is error you are not getting SoapObject that time u will get SoapFault object u have to handle that
Upvotes: 1