Skip to content

Instantly share code, notes, and snippets.

@ruslan-hut
Created December 25, 2018 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruslan-hut/8027de7fcc12528b5dfcf82908c6b9c0 to your computer and use it in GitHub Desktop.
Save ruslan-hut/8027de7fcc12528b5dfcf82908c6b9c0 to your computer and use it in GitHub Desktop.
@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