使用(tomcat + AXIS2)的Java Web服务,应用程序的根目录在哪里?
|
我创建了一个将图像下载到本地Web服务器的功能。
当我像Java应用程序一样运行此功能时,它可以正常工作。但是,当我尝试使用AXIS2制作的Web服务(http:// localhost:8080 / axis2 / services / adoroCinemaService2 / downloadPhoto)运行此方法时,AXIS2返回内部服务器错误。
这很可能发生,因为我在代码中使用了\“ root 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();
}
没有找到相关结果
已邀请:
1 个回复
哩翔购