i am using tomcat7.0,jdk1.6,and i downloaded the jax-wsri jar files.
first i created folder named ws in webapps in tomcat folder.
then in ws folder i created WEB-INF folder and META-INF.and in WEB-INF i created folder classes&folder lib.
then i created the web service class as follows
package hello;import javax.jws.WebMethod;import javax.jws.WebService;import javax.jws.*;import javax.xml.ws.Endpoint;@WebService public class HelloWorld{@WebMethod public String Hello(){String s;s="Hello";return s;}public static void main(String[] args) { Endpoint.publish("http://localhost:8080/ws/hello", new HelloWorld()); }}package hello;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.*;
import javax.xml.ws.Endpoint;
@WebService public class HelloWorld{
@WebMethod public String Hello(){
String s;
s="Hello";
return s;
}
public static void main(String[] args) {
Endpoint.publish("http://localhost:8080/ws/hello",
new HelloWorld());
}
}
i compiled it and saved HelloWorld.class in:webapps\ws\WEB-INF/classes\HelloWorld.class
after that i created web.xml that is
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <listener><listener-class> com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class></listener><servlet><servlet-name>Hello</servlet-name><servlet-class>HelloWorld</servlet-class></servlet><servlet-mapping> <servlet-name>Hello</servlet-name><url-pattern>/HelloWorld</url-pattern></servlet-mapping></web-app><?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<listener>
<listener-class>
com.sun.xml.ws.transport.http.servlet.WSServletContextListener
</listener-class>
</listener>
<servlet>
<servlet-name>Hello</servlet-name>
<servlet-class>
HelloWorld
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Hello</servlet-name>
<url-pattern>/HelloWorld</url-pattern>
</servlet-mapping>
</web-app>
and saved it in webapps/ws/WEB-INF
then i created sun-jaxws
<?xml version="1.0" encoding="UTF-8"?> <endpoints version="2.0" xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"> <endpoint implementation="hello.HelloWorld" name="HelloWorld" url-pattern="/HelloWorld"/> </endpoints><?xml version="1.0" encoding="UTF-8"?> <endpoints version="2.0" xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"> <endpoint implementation="hello.HelloWorld" name="HelloWorld" url-pattern="/HelloWorld"/> </endpoints>
and save it in webapps/ws/WEB-INF
i moved also all jar files from jaxws-ri to webapps\ws\WEB-INF\lib directory
after that i run tomcat and browse through the address http://localhost:8080/ws/HelloWorld/
but i am receiving the requested resource is not available.
i don't know if anybody can help
regards