Created
December 25, 2018 09:42
-
-
Save ruslan-hut/8027de7fcc12528b5dfcf82908c6b9c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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