Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@Nullable
private SoapObject getData(String objectCode) {
errorText = "";
SoapObject request = new SoapObject(NAMESPACE, "get");
PropertyInfo param = new PropertyInfo();
param.setName("objectCode");
param.setValue(objectCode);
request.addProperty(param);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
//авторизация
List<HeaderProperty> headerList = new ArrayList<HeaderProperty>();
headerList.add(new HeaderProperty("Authorization", "Basic "+org.kobjects.base64.Base64.encode(USER_PASSWORD.getBytes())));
//выполнение запроса к веб-сервису
try {
androidHttpTransport.call(SOAP_ACTION, envelope, headerList);
} catch (IOException e) {
errorText = "CONNECTION_ERROR";
return null;
} catch (XmlPullParserException e) {
errorText = "XML_ERROR";
return null;
}
Object result = envelope.bodyIn;
if (result != null) {
try {
return (SoapObject) result;
}catch (Exception e){
Log.e("KSOAP", result.toString());
}
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.