Deploying Web Service to Tomcat

Source: Internet
Author: User

Open JDeveloper 12c, then create a new Java project, click Java, and build Web services.

Package simple;

Import Javax.jws.WebMethod;
Import Javax.jws.WebParam;
Import Javax.jws.WebService;

@WebService
public class HelloWorld {
Public HelloWorld () {
Super ();
}

@WebMethod
public string SayHelloWorld (@WebParam (name = "arg0") string username) {
Return "Hello" +username;
}
}

Add Sun-jaxws.xml under Web-inf, with the following content

<?xml version= "1.0" encoding= " GBK,
<endpoints
xmlns= "http://java.sun.com/xml/ns/ Jax-ws/ri/runtime "
version=" 2.0 "
<endpoint
" Span style= "font-family: ' Courier New ', courier; font-size:14px; " > Name= "HelloWorld"
Implementation= "simple. HelloWorld "
url-pattern="/ Helloworldport "/>
</ Endpoints>

Modify Web. XML to read as follows:

<?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 does not support remote deploy and chooses to deploy into a war file,

Download the JAX-ws package, https://jax-ws.java.net/, and then press the jar file into the/lib folder after it is truncated.

Put WebApp1 into $catalina_home/webapps, then modify Conf under Tomcat-users.xml, add the following paragraph

<role rolename= "Manager-gui"/>
<user username= "Tomcat" password= "Tomcat" roles= "Tomcat,manager-gui"/>

Open http://10.182.170.6:8080/, select Manager app

You can see that the WEBAPP1 has been deployed successfully.

Browse Http://10.182.170.6:8080/webapp1/HelloWorldPort to display the content of the deployment Web service

Deploying Web Service to Tomcat

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.