简体   繁体   English

使用Web服务本身中的资源axis2吗?

[英]Using resources in web service itself axis2?

I have deployed a web service with axis2 via eclipse. 我已经通过eclipse用axis2部署了一个Web服务。 I also have a XML file to store the data that should be used by the new web service. 我还有一个XML文件来存储新Web服务应使用的数据。 After creating the web service, I recognized the xml file has been put into WebContent/WEB-INF/classes folder. 创建Web服务后,我认识到xml文件已放入WebContent / WEB-INF / classes文件夹中。 I failed to open it with my new web service. 我无法使用新的Web服务打开它。 The fault message is: "java.io.FileNotFoundException: xmlfile.xml (The system cannot find the file specified)" I deployed it as bottom-up and the code that used to open the xml file is: 错误消息是:“ java.io.FileNotFoundException:xmlfile.xml(系统找不到指定的文件)”我以自下而上的方式部署了该文件,用于打开xml文件的代码为:

File xmlDocument = new File("xmlfile.xml");

It works when the xml file in the same directory with java file, but in the web service, it doesn't work. 当xml文件与java文件位于同一目录中时,它可以工作,但是在Web服务中,它不起作用。 How to use the resources in an axis2 web service? 如何在axis2 Web服务中使用资源? Please help 请帮忙

I don't have any experience on JAVA WEB development, but, in your case, is the XML file located in some package that has a class? 我没有JAVA WEB开发方面的经验,但是,就您而言,XML文件是否位于具有类的某些程序包中? If its true, you could do something like that: 如果属实,则可以执行以下操作:

URL url = ClassFromSamePackageOfFile.class.getResource( "xmlfile.xml" );

File f;
try {
  f = new File(url.toURI());
} catch(URISyntaxException e) {
  f = new File(url.getPath());
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM