蒙奇D么么哒 2010-07-11 16:55 采纳率: 0%
浏览 240
已采纳

axis 开发webservice问题

最近研究axis的webservice 有个位搞不定 ,卡啦一天发出来请大家帮忙解决下!
是这样,service端我都配好了,deploy.wsdd的文件如下:



<deployment xmlns="http://xml.apache.org/axis/wsdd/"
                        xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">     
    <service name="HelloWord" provider="java:RPC">   
        <parameter name="className" value="resunly.service.HelloWord" />   
        <parameter name="allowedMethods" value="*" />        
    </service>   
</deployment> 
 

在cmd 下也生成啦 相应的 server-config.wsdd 文件,然后写类:HelloWrod 代码如下:

package resunly.service;

public class HelloWrod {

    public HelloWrod(){
        
    }
    public String hello(String name){
        return "hello"+name;
    }
    
    public int getNum(int num,int end){
        return num+end;
    }
}

 

并将此类生成的class文件放到了E:\Program\tomcat\apache-tomcat-6.0.18\webapps\axis\WEB-INF\classes\resunly\service 下,客户端的的调用代码如下:

package resunly.client;

import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;

import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;

public class TestWebService {

    /**
     * @param args
     */
    public static void main(String[] args) {
        String SeverAdd = "http://localhost:8080/axis/resunly/service/HelloWord";
        Service service = new Service();
        try {
            Call call = (Call) service.createCall();
            call.setTargetEndpointAddress(new URL(SeverAdd));
//          call.setOperationName(new QName(SeverAdd,"hello"));
//          String result = (String)call.invoke(new Object[]{"resunly"});
//          System.out.println(result);
            
            call.setOperationName(new QName(SeverAdd,"getNum"));
            Integer res = (Integer)call.invoke(new Object[]{new Integer(1),new Integer(3)});
            System.out.println(res);
        } catch (ServiceException e) {
            e.printStackTrace();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }

}

然后,run 就报错!报错内容如下:

AxisFault
 faultCode: {http://xml.apache.org/axis/}HTTP
 faultSubcode: 
 faultString: (404)Not Found
 faultActor: 
 faultNode: 
 faultDetail: 
    {}:return code:  404
&lt;html&gt;&lt;head&gt;&lt;title&gt;Apache Tomcat/6.0.18 - Error report&lt;/title&gt;&lt;style&gt;&lt;!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--&gt;&lt;/style&gt; &lt;/head&gt;&lt;body&gt;&lt;h1&gt;HTTP Status 404 - /axis/resunly/service/HelloWord&lt;/h1&gt;&lt;HR size=&quot;1&quot; noshade=&quot;noshade&quot;&gt;&lt;p&gt;&lt;b&gt;type&lt;/b&gt; Status report&lt;/p&gt;&lt;p&gt;&lt;b&gt;message&lt;/b&gt; &lt;u&gt;/axis/resunly/service/HelloWord&lt;/u&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;description&lt;/b&gt; &lt;u&gt;The requested resource (/axis/resunly/service/HelloWord) is not available.&lt;/u&gt;&lt;/p&gt;&lt;HR size=&quot;1&quot; noshade=&quot;noshade&quot;&gt;&lt;h3&gt;Apache Tomcat/6.0.18&lt;/h3&gt;&lt;/body&gt;&lt;/html&gt;
    {http://xml.apache.org/axis/}HttpErrorCode:404

(404)Not Found
    at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:744)
    at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:2443)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at resunly.client.TestWebService.main(TestWebService.java:29)

 提示是在   Integer res = (Integer)call.invoke(new Object[]{new Integer(1),new Integer(3)});
这里报的错 ,上面注释的也是在这里报的错,不知道为什么 ,卡啦半天搞不定啦 ,求指点 ,感激不尽!

 

  • 写回答

1条回答 默认 最新

  • DK101 2010-07-13 16:53
    关注

    提示的是资源没有找到,个人认为是这行代码有问题“String SeverAdd = "http://localhost:8080/axis/resunly/service/HelloWord";

    ”,修改成这样试试“String SeverAdd = "http://localhost:8080/axis/service/HelloWord";

    ”。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料