• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

On the implementation of Android Oreo HttpURLConnection

Hello

Where I installed it on Android Oreo's device
The transmission result of WebService has changed.

There is no problem until Android nougat

In Android Oreo, specification of HttpURLConnection changed
Please tell me if you know the missing settings in the following sources.

----------------------------------------------------------------

HttpURLConnection connection;

URL targetUrl = "http://[hostname]/XXX/XXXX.asmx"

connection = (HttpsURLConnection) targetUrl.openConnection();
connection.setConnectTimeout(timeout);
connection.setReadTimeout(timeout);
connection.setInstanceFollowRedirects(false);
connection.setRequestMethod("POST");
connection.setUseCaches(false);
connection.setDoInput(true);

// create header
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/soap+xml; charset=utf-8");
connection.setRequestProperty(header.getKey(), header.getValue());

// create body
String body =
"<?xml version='1.0' encoding='utf-8' ?>"
+
"<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">"
+
"<soap12:Body>"
+
"<XXXXXXXX xmlns="http://localhost/">"
+
"<inputParameters>value</inputParameters>"
+
"</SendUploadFileInfoList>"
+
"</soap12:Body>"
+
"</soap12:Envelope>";

byte[] postDataBytes = body.getBytes("UTF-8");
connection.setRequestProperty("Content-Length", String.valueOf(postDataBytes.length));
connection.getOutputStream().write(postDataBytes);

// connect
connection.connect();

int code = connection.getResponseCode();
Map<String, List<String>> header = connection.getHeaderFields();

--Hereinafter omitted...
 
Thank you very much.

I am investigating what the problem is, so I can not explain it.

in the gradle file
· CompileSdkVersion from 25 to 26
· TargetSdkVersion from 24 to 26
I changed it and executed it, but I get an error.

I read the API reference, reviewed the setting method and executed it
It could not be solved.

Errors have been resolved by making the following settings.
Why is this cause and how to deal with it?
If you have a bug report, please let me know.

Terminal: Nexsus 5X
API Level: 26

1. Set the proxy in the WiFi of the connection destination
In case
2. Connect the Android terminal and the proxy to the same WiFi

3. If you communicate, you can send to WebService (SOAP 1.2) normally.
 
Back
Top Bottom