здесь - фрагменты кода, которые я использую для публикации xml в сервисах SOAP и получения взамен Inputstream из Интернета.
private InputStream call(String soapAction, String xml) throws IOException {
byte[] requestData = xml.getBytes("UTF-8");
URL url = new URL(URL);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty("Accept-Charset", "UTF-8");
// connection.setRequestProperty("Accept-Encoding","gzip,deflate");
connection.setRequestProperty("Content-Type", "text/xml; UTF-8");
connection.setRequestProperty("SOAPAction", soapAction);
connection.setRequestProperty("User-Agent", "android");
connection.setRequestProperty("Host",
"base_urlforwebservices like - xyz.net");
// connection
// .setRequestProperty("Content-Length", "" + requestData.length);
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setDoInput(true);
os = connection.getOutputStream();
os.write(requestData, 0, requestData.length);
os.flush();
os.close();
is = connection.getInputStream();
return is; // inputStream
}
Здесь xml: встроенный запрос xml, используемый для вызова служб.
Веселись;