build.xml
config.xml
webservices.xml
Hello.java /* * @author roson * * 2005-10-10 */ package helloservice; import java.rmi.Remote; import java.rmi.RemoteException; public interface Hello extends Remote { public String sayHello(String name) throws RemoteException; } |
HelloImpl.java /* * @author roson * * 2005-10-10 */ package helloservice; import java.rmi.RemoteException; public class HelloImpl implements Hello { public String message="hello:"; public String sayHello(String name) throws RemoteException { return message+name; } } |
Client.java /* * @author roson * * 2005-10-11 */ package client; import helloservice.Hello; import javax.xml.rpc.Service; import javax.xml.rpc.ServiceFactory; import javax.xml.namespace.QName; import java.net.*; public class Client { public static void main(String[] args) throws Exception { URL url=new URL("http://netone:8080/webservice/hello?wsdl"); QName qName=new QName("http://netone.com/Hello","HelloService"); ServiceFactory factory=ServiceFactory.newInstance(); Service service=factory.createService(url,qName); Hello hello=(Hello)service.getPort(Hello.class); System.out.println(hello.sayHello("rosonsandy")); } } |
首先要自己配置path和jboss_home
生成mapping.xml
运行ant generate-mapping
生成HelloService.wsdl
运行ant wscompile
然后把这些文件照图片放置。
部署ant war
查看在Jboss中的HelloService:
http://localhost:8080/ws4ee/
http://localhost:8080/ws4ee/services
就可以运行client了。在eclipse中 -->run as-->java application
说明:
关于最新的EJB3.0与WebService的协同合作,JBoss将在JBoss5.0中完成。
wscompile和wsdeploy的ant设置可以参考
http://java.sun.com/webservices/docs/1.3/jaxrpc/jaxrpc-tools.html
https://jax-rpc.dev.java.net/whitepaper/1.1/index-part1.html