51Testing软件测试论坛

标题: 求助:有没有大神会hessian的?。求助。 [打印本页]

作者: 13636615621    时间: 2015-12-22 08:17
标题: 求助:有没有大神会hessian的?。求助。
文档:
接口调用:
接口类型        Hessian
请求Url        http://kaifu.5173.com/MobileKfInfo.hessian
接口定义:
方法名称        返回值类型              返回值说明
GetMobileAdData        字符串        Json数组格式的字符串
方法名称        返回值类型        返回值说明
GetMobileKfData        字符串        Json数组格式的字符串
接口参数:
参数名/类型
pageIndex/整数
pageSize/整数

以下是我根据百度一些教程写的代码:
package hessian;

public interface Basic {
       
            String Hello(String name);

            String GetMobileAdData();

            String GetMobileKfData(int pageIndex, int pageSize);
        }

       
//用来给客户端调用的提供服务的接口



package hessian;

public class basicservice implements Basic {

        public String Hello(String name) {
                // TODO Auto-generated method stub
                return "Hello";
        }

        public String GetMobileAdData() {
                // TODO Auto-generated method stub
                return "Hello";
        }

        public String GetMobileKfData(int pageIndex, int pageSize) {
                // TODO Auto-generated method stub
                return "Hello:"+pageIndex+pageSize;
        }

}
//实现该接口的功能




package hessian.test.client;

import java.net.MalformedURLException;

import com.caucho.hessian.client.HessianProxyFactory;


import hessian.Basic;

public class HessianClient {

         public static void main(String[] args) throws MalformedURLException {
               
                String url = "http://kaifu.5173.com/MobileKfInfo.hessian";
                HessianProxyFactory factory = new HessianProxyFactory();
                Basic basic = (Basic) factory.create(Basic.class, url);
                System.out.println("Hello:"+  basic.Hello(url));
                System.out.println("Hello:"+  basic.GetMobileAdData());

        }
}

//HessianClient客户端



但是运行之后报错,没有返回内容。。报错如下:
Exception in thread "main" com.caucho.hessian.client.HessianRuntimeException: com.caucho.hessian.io.HessianProtocolException: '6' is an unknown class definition
        at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:222)
        at com.sun.proxy.$Proxy0.Hello(Unknown Source)
        at hessian.test.client.HessianClient.main(HessianClient.java:17)
Caused by: com.caucho.hessian.io.HessianProtocolException: '6' is an unknown class definition
        at com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1727)
        at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:207)
        ... 2 more




哪位大神指导下。。。。

作者: 13636615621    时间: 2015-12-22 08:23
顶顶
作者: 13636615621    时间: 2015-12-22 08:44
自己顶下
作者: 13636615621    时间: 2015-12-22 09:13
自己顶!d=====( ̄▽ ̄*
作者: 13636615621    时间: 2015-12-22 09:41
没有大神指导么
作者: qizhuo    时间: 2015-12-22 09:41
帮顶下
作者: zhangwenyan01    时间: 2015-12-22 10:50
悄悄的来我又悄悄的走了
作者: joykao    时间: 2015-12-22 15:44
你的服务地址注册过吗?服务的jar包引入了或者Basic的那个工程引进了?你call的那个服务的地址必须是在中心里注册的,不然是无效的




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2