我已经编写了一个简单的java文件Calculator.java,如下所示
public class Calculator {
public int add(int a, int b) {
return a+b;
}
public int subtract(int a, int b) {
return a-b;
}
}
现在,我将其重命名为Calculator.jws并将其放入我的Web应用程序的根目录中 . (与WEB-INF目录在同一目录中) . 当我尝试使用http://localhost:8680/webappcontextroot/Calculator.jws访问此Web服务时,我收到一条消息说
“这里有一个Web服务 . 点击查看WSDL”
当我点击链接看到WSDL文件时,我收到一个错误,
AXIS错误
无法生成WSDL!
此位置没有SOAP服务
当我写一个客户端来调用Web服务时,我得到了一个Axis错误
- Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled.
Exception in thread "main" AxisFault
faultCode: {http://xml.apache.org/axis/}Server.NoService
faultSubcode:
faultString: The AXIS engine could not find a target service to invoke! targetService is null
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}hostname:D78D46BS
AXIS引擎无法找到要调用的目标服务! targetService为null
似乎缺少WSDL文件;但是oreilly教程告诉你所要做的只是将你的java文件复制到.jws文件并将其放入你的webapp中,webservice就可以使用了 .
有人可以帮我弄这个吗?
1 回答
仅在错误消息上,您的类路径中似乎缺少mailapi.jar和activation.jar库 . 将它们放在axis.jar所在的同一文件夹中,然后重新启动Web服务器 .