JAX-WS implementation in JBOSS:
- created a dynamic project in eclipse HelloWorld
- created our service class(my package is ws.simple)
- Edited the web.xml as follows:
Added the entries below:
<servlet>
<servlet-name>HelloService</servlet-name>
<servlet-class>ws.simple.HelloService</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>HelloService</servlet-name>
<url-pattern>/service</url-pattern>
</servlet-mapping>
- Exported as war file in jboss
Location for the wsdl file is :
C:\Users\jboss\jb\4.3.0\server\production\data\wsdl\HelloWorld.war\HelloServiceService7961998949159727873.wsdl
The wsdl file is as follows:
http://localhost:7001/HelloWorld/service?wsdl
- Now, we consume this web service by creating client using utilities provided by JBossWS stack ( Examples include wsconsume, wsget, wsrunclient etc )
C:\Users\jboss\jb\4.3.0\bin>wsconsume.bat -k http://localhost:7001/HelloWorld/se
rvice?wsdl
Files are generated in the below location:
C:\Users\jboss\jb\4.3.0\bin\output\ws\simple
- I have created a Sample Client Project and put these generated files in ws.simple
- Created Client Class TestWSClient.java
package ws.simple;
public class TestWSClient
{
public static void main(String[] args)
{
HelloServiceService service =new HelloServiceService();
HelloService helloServ=service.getHelloServicePort();
String msg=helloServ.sayHello("Amit Das! Merry Christmas");
System.out.println(msg);
}
}
Running as java application generates as:
Hello, Amit Das! Merry Christmas