楼上的,我的这个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>
我的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>
解决方案 »
- 学习JBPM该看那些资料呢
- jdbc连接数据库的查询效率问题
- 【求助】Myeclipse利用xfire自动创建webservice client端代码
- jquery中的tablesorter支持动态数据更新吗?
- 请问我想做一个网页模板,要求这个模板根据传参的不同显示不一样的内容,请问怎么办?(比如参数1网页只显示模板中的表格,参数2则显示表格+选择项)
- 探讨关于J2EE客户端数据获取与回写模式!
- struts错误,请高人解答
- 有没有介绍java 类库这样的书
- 请问怎样在WebSphere下部署和发布EJB?????
- client 访问ejb时的错!help!
- 问个初级问题,weblogic8.1+jbuilder9的配置
- 一个关于程序结构的问题,如果我使用struts和hibernate,我struts的ActionForm的内容和hibernate里model对应的一个类的内容一样的,我怎
帮你顶,希望早点解决
利用本机读取方式提示找不到文件??
晕???,。。还有人么?????????
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());
}
}
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相关的相对路径;这样不用改变环境就可以
完成相应的工作!
如果你使用的是Axis,可以这样得到路径。MessageContext mc = MessageContext.getCurrentContext();
String homeDir = mc.getStrProp(Constants.MC_HOME_DIR);