楼上的,我的这个web service 的method 方法调用时提示找不到文件,
我的data.xml和该服务的class文件放在一个目录下的: public String readXML() throws Exception
{
XercesDOMAdapter xercAdapter = new XercesDOMAdapter();
DOMBuilder builder  =new DOMBuilder("org.jdom.adapters.XercesDOMAdapter");
org.w3c.dom.Document w3dom = xercAdapter.getDocument(new FileInputStream("data.xml"),false);
Document docA = builder.build(w3dom);
List list = docA.getRootElement().getChildren();
String strname="";
for (Iterator it = list.iterator(); it.hasNext(); ) 
{
strname=strname+((Element) it.next()).getName();
}
return strname;
}访问地址:
http://localhost:8080/axis/services/axisServiceCall?method=readXML
出错信息:
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <soapenv:Body>
- <soapenv:Fault>
  <faultcode>soapenv:Server.userException</faultcode> 
  <faultstring>java.io.FileNotFoundException: data.xml (系统找不到指定的文件。)</faultstring> 
- <detail>
  <ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">lgb</ns1:hostname> 
  </detail>
  </soapenv:Fault>
  </soapenv:Body>
  </soapenv:Envelope>

解决方案 »

  1.   

    写一个类似webconfig的文件,进行读取就可以了,其中的节点配置可自己控制。
    帮你顶,希望早点解决
      

  2.   

    web 服务如何读取服务器上的配置文件啊????
    利用本机读取方式提示找不到文件??
    晕???,。。还有人么?????????
      

  3.   

    你在服务器端写好读取本地文件的服务,用WebService去调用,获得文件就可以了。服务器在远程还让你直接读写文件,好像也不安全亚。
      

  4.   

    你如果读取本地文件不对,那就不是WebServices的问题了,是读Xml有问题。
      

  5.   

    楼上的,我的程序用本地读取的时候都没有问题的,控制台中显示:
    NeGrid但原样班到axis中的classess目录下,在地址栏输入:
    http://localhost:8080/axis/services/axisServiceCall?method=readXML
    wsdl提示找不到文件啊!!!public void readXML() throws Exception
    {
    XercesDOMAdapter xercAdapter = new XercesDOMAdapter();
    DOMBuilder builder  =new DOMBuilder("org.jdom.adapters.XercesDOMAdapter");
    org.w3c.dom.Document w3dom = xercAdapter.getDocument(new FileInputStream("data.xml"),false);
    Document docA = builder.build(w3dom);
    List list = docA.getRootElement().getChildren();
    for (Iterator it = list.iterator(); it.hasNext(); ) 
    {
    System.out.println(((Element) it.next()).getName());
    }
    }
      

  6.   

    web应用的代码默认的文件位置是启动 app server的位置,不过按道理这个文件应该放到 某个应用的WEB-INF目录下。 Servlet里的API应该有一些方法可以得到这些真实的路径。比如getRealPath什么的。
      

  7.   

    我采用绝对路径就能访问,例如把
    org.w3c.dom.Document w3dom = xercAdapter.getDocument(new FileInputStream("data.xml"),false);改成:
    org.w3c.dom.Document w3dom = xercAdapter.getDocument(new FileInputStream("d:\\data.xml"),false);
    就能读取,关键是我想如何该成和我的class相关的相对路径;这样不用改变环境就可以
    完成相应的工作!
      

  8.   

    你这个要求是很合理的。一般的SDK都考虑到了这个问题。
    如果你使用的是Axis,可以这样得到路径。MessageContext mc = MessageContext.getCurrentContext();
    String homeDir = mc.getStrProp(Constants.MC_HOME_DIR);