0
我创建了一个将图像下载到本地Web服务器的功能。 当我像Java应用程序一样运行这个函数时,它工作正常。但是,当我尝试使用由AXIS2(http://localhost:8080/axis2/services/adoroCinemaService2/downloadPhoto)生成的Web Service运行此方法时,AXIS2返回内部服务器错误。Java中使用(tomcat + AXIS2)的Web服务,其中是应用程序的根?
它发生的可能性很大,因为我在我的代码中使用了“根路径”。那么,我需要做些什么来解决这个问题呢?我的服务的根源在哪里?我如何设置此路径?
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();
}