tomcat下使用jax-ws的RI环境 jaxws

Deploy JAX-WS Web Services On Tomcat



Posted on November 23, 2010Bymkyong

2. sun-jaxws.xml

Create a web service deployment descriptor, which is also known asJAX-WS RI deployment descriptor– sun-jaxws.xml.

File : sun-jaxws.xml

<?xml version="1.0" encoding="UTF-8"?><endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime" version="2.0"> <endpoint name="HelloWorld" implementation="com.mkyong.ws.HelloWorldImpl" url-pattern="/hello"/></endpoints>

When user access/hello/URL path, it will fire the declared web service, which isHelloWorldImpl.java.

Note

For detail endpoint attributes , see thisarticle.

3. web.xml
tomcat下使用jax-ws的RI环境 jaxws

Create a standard web.xmldeployment descriptorfor the deployment. DefinesWSServletContextListeneras listener class,WSServletas your hello servlet.

File : web.xml

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN""http://java.sun.com/j2ee/dtds/web-app_2_3.dtd"><web-app> <listener> <listener-class> com.sun.xml.ws.transport.http.servlet.WSServletContextListener </listener-class> </listener> <servlet> <servlet-name>hello</servlet-name> <servlet-class> com.sun.xml.ws.transport.http.servlet.WSServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>hello</servlet-name> <url-pattern>/hello</url-pattern> </servlet-mapping> <session-config> <session-timeout>120</session-timeout> </session-config></web-app>

4. WAR Content

Use Ant, Maven or JAR command to build a WAR file to include everything inside. The WAR content should look like this :

WEB-INF/classes/com/mkyong/ws/HelloWorld.classWEB-INF/classes/com/mkyong/ws/HelloWorldImpl.classWEB-INF/web.xmlWEB-INF/sun-jaxws.xml

Note

For those who are interested, here’s the Ant file to build this project and generate the WAR file.File : build.xml

<project name="HelloWorldWS" default="dist" basedir="."> <description> Web Services build file </description> <!-- set global properties for this build --> <property name="src" location="src"/> <property name="build" location="build"/> <property name="dist" location="dist"/> <property name="webcontent" location="WebContent"/> <target name="init"> <!-- Create the time stamp --> <tstamp/> <!-- Create the build directory structure used by compile --> <mkdir dir="${build}"/> </target> <target name="compile" depends="init" description="compile the source " > <!-- Compile the java code from ${src} into ${build} --> <javac srcdir="${src}" destdir="${build}"/> </target> <target name="war" depends="compile" description="generate the distribution war" ><!-- Create the war distribution directory --> <mkdir dir="${dist}/war"/> <!-- Follow standard WAR structure --> <copydir dest="${dist}/war/build/WEB-INF/" src="${webcontent}/WEB-INF/" /> <copydir dest="${dist}/war/build/WEB-INF/classes/" src="${build}" /><jar jarfile="${dist}/war/HelloWorld-${DSTAMP}.war" basedir="${dist}/war/build/"/> </target></project>

5. JAX-WS Dependencies

By default, Tomcat does not comes with anyJAX-WS dependencies, So, you have to include it manually.

1. Go herehttp://jax-ws.java.net/.

2. Download JAX-WS RI distribution.

3. Unzip it and copy following JAX-WS dependencies to Tomcat library folder “{$TOMCAT}/lib“.

jaxb-impl.jar

jaxws-api.jar

jaxws-rt.jar

gmbal-api-only.jar

management-api.jar

stax-ex.jar

streambuffer.jar

policy.jar

6. Deployment

Copy the generatedWARfile to{$TOMCAT}/webapps/folder and start the Tomcat server.

For testing, you can access this URL :http://localhost:8080/HelloWorld/hello, if you see following page, it means web services are deploy successfully.

  

爱华网本文地址 » http://www.413yy.cn/a/25101011/53531.html

更多阅读

win7环境下红色警戒2的联网问题 红色警戒联网平台

win7环境下红色警戒2的联网问题——简介红警2是个很老的游戏了,与现在的主流win7系统有些冲突。虽然能玩一下单机游戏,但是不能连接局域网。如果你有此类麻烦,来这儿就对了。win7环境下红色警戒2的联网问题——工具/原料

一次性筷子的危害究竟有哪些? 使用一次性筷子的危害

随着制造业的飞速发展,越来越多的使用品打上了一次性的烙印。一次性针头,一次性纸杯,一次性筷子等等,越来越多的一次性物品在给我们的生活带来了许多方便和舒适的同时,也为我们的生活带来了些许无奈和伤害。也许是因为时间紧迫,你不得不

Windows7下启用IIS7配置ASP运行环境的详细方法 iis7启用父路径

第一次在windows7下配置IIS,虽然有丰富的xp下配置IIS的经验,但还是会遇到不少的问题。特别是对入门者来说,搞清一些东西还是挺费时间的。其实win7下的IIS7配置过程是非常简单的。下面让seo博客来详细的介绍一下win7下配置IIS7环境运行A

在Linux下使用ipmsg飞鸽传书 飞鸽传书 linux 64

2007年03月31日 16:01ipmsg是个不错的局域网通讯软件,非常小巧,无需服务器端,使用非常方便。在Linux下使用需要自行编译。在官方网站下载源码:http://www.ipmsg.org/index.html.en解压后需要修改源码以支持中文:文件:src/codeset.c原文:#de

声明:《tomcat下使用jax-ws的RI环境 jaxws》为网友虐爆托儿所分享!如侵犯到您的合法权益请联系我们删除