|
文档:
接口调用:
接口类型 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
哪位大神指导下。。。。
|
|