打开jdeveloper 12c,然后新建一个java项目,点击java,生成web services.
package simple; import javax.jws.WebMethod; @WebService @WebMethod |
在WEB-INF下添加sun-jaxws.xml,内容如下
<?xml version="1.0" encoding="GBK" ?> <endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime" version="2.0"> <endpoint name="HelloWorld" implementation="simple.HelloWorld" url-pattern="/HelloWorldPort"/> </endpoints> |
修改web.xml,内容如下:
<?xml version = ‘1.0‘ encoding = ‘GBK‘?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <listener> <listener-class> com.sun.xml.ws.transport.http.servlet.WSServletContextListener </listener-class> </listener> <servlet> <servlet-name>HelloWorldPort</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>HelloWorldPort</servlet-name> <url-pattern>/HelloWorldPort</url-pattern> </servlet-mapping> </web-app> |
Jdeveloper 12.1.3不支持远程deploy,选择deploy成一个war文件,
下载jax-ws包,https://jax-ws.java.net/,然后截压后将jar文件放入/lib文件夹下.
将webapp1放入$catalina_home/webapps,然后修改conf下tomcat-users.xml,加入下面这段
<role rolename="manager-gui"/>
<user username="tomcat" password="tomcat" roles="tomcat,manager-gui"/>
打开http://10.182.170.6:8080/,选择manager app
可以看到webapp1已经部署成功.
浏览http://10.182.170.6:8080/webapp1/HelloWorldPort,显示部署web service的内容