posted 9 years ago
Hello,
I'm accessing a WebService with BasicAuthentication from my WebApplication. The Answer from the WebService is a XML-File (but that should not matter, because only the InputStream is needed).
I implemented 2 Versions, one using the "java.net.HttpURLConnection" and the other using "org.apache.http".
The Connection with the java.net package takes about ~100ms and the Connection with the "org.apache.http" package takes about ~500ms. Since I'm requesting 220 different Files from the server, both are too slow for my usage.
I think I could enhance the performance by keeping the connection open and just requesting the next File, but i dont know how to do that.
Since I'm getting my "HttpURLConnection" from my URL i dont know how to request a different file.
For example I request something like: "https://myServer/device1/status" and after that i want to request "https://myServer/device2/status". Is there a way to connect to "https://myServer/" and then change the parameters to "device1/status" etc.?
Thank You
Markus
Edit: I did some followup reading and found out that HttpURLConnection is based on the Socket implementation and therefor "inherits" the keep alive functions, as long the connection is not explicitly closed.
But i still need to increase the speed. The Service prepares data for a WebSite, which currently takes ~25s to load.