I create a function that downloads a image to my local web server. When I run this function like a Java Application, it works fine. But when I try to run this method using the Web Service made by AXIS2 ( http://localhost:8080/axis2/services/adoroCinemaService2/downloadPhoto ), the AXIS2 returns Internal server error.
It happens probabily, because I use a "root path" in my code. So, what I need to do to solve this problem? Where is the root of my service? How can I setup this path?
public void downloadPhoto() throws IOException{
URL url = new URL("http://vamosla.mobi/img/bonde.png");
String target = "vamosla.jpg";
HttpURLConnection c = (HttpURLConnection)url.openConnection();
c.setRequestMethod("GET");
c.setDoOutput(true);
c.connect();
FileOutputStream f = new FileOutputStream(new File(target));
InputStream in = c.getInputStream();
byte[] buffer = new byte[1024];
int len1 = 0;
while ( (len1 = in.read(buffer)) > 0 ) {
f.write(buffer,0, len1);
}
f.close();
}