Hessian HTTP调用的问题 在线静候大驾

cjoy4856 2010-07-13 08:55:31
我按照caucho 官方网站上的实例做 但是我一直没有弄懂一个问题 :
1.就是我想通过浏览器查看我的hessian 为什么不能查看但是我使用测试类就能调用
2.再之 ,如果RMI就是1的这中方式 那它的存在有什么意义 (我的想法是hessian能够像WebService一样,在客户端就能使用,通过时wsdl的文件生成 调用服务端的必要类。但是如果hessian能想webservice一样,我改这么去修改)。
下面是我的代码
1。service Interface

package whao.test.hessian.official.server;

public interface BasicAPI {
public String hello();
}

2.service Imp

package whao.test.hessian.official.server.impl;

import whao.test.hessian.official.server.BasicAPI;
import com.caucho.hessian.server.HessianServlet;
public class BasicService extends HessianServlet implements BasicAPI {

private String _greeting = "Hello, world";
public void set_greeting(String greeting) {
_greeting = greeting;
}
public String hello() {
// TODO Auto-generated method stub
return _greeting;
}
}


3. web.xml

<servlet>
<servlet-name>hello</servlet-name>
<servlet-class>com.caucho.hessian.server.HessianServlet</servlet-class>
<init-param>
<param-name>home-class</param-name>
<param-value>whao.test.hessian.official.server.impl.BasicService</param-value>
</init-param>
<init-param>
<param-name>home-api</param-name>
<param-value>whao.test.hessian.official.server.BasicAPI</param-value>
</init-param>
</servlet>
<servlet-mapping>
<url-pattern>/hello</url-pattern>
<servlet-name>hello</servlet-name>
</servlet-mapping>

4。测试类

import java.net.MalformedURLException;

import whao.test.hessian.official.server.BasicAPI;

import com.caucho.hessian.client.HessianProxyFactory;

public class Test {
public static void main(String[] args) throws MalformedURLException {
// TODO Auto-generated method stub
//为什么使用HTTP访问不行
String url = "http://localhost:8089/hessian/hello";
HessianProxyFactory factory = new HessianProxyFactory();
BasicAPI basic = (BasicAPI) factory.create(BasicAPI.class, url);
System.out.println("Hello: " + basic.hello());//结果是Hello: Hello, world 成功了
}
}


请大侠能说的详细一点。如果大侠有更好的学习实例给一份学习(joylovenba@163.com)。谢谢!!!
...全文
151 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧