Read JAX-WS WebService as Web Archive .war by Tomcat first before going ahead with Web Services Client Code by JSP.
Dynamic web project is alread there in "JAX-WS WebService as Web Archive .war by Tomcat" tutorial. Just we have to add the JSP and few line of code for creating the Web Services Client.
Open the Eclipse, open the dynamic web project "jaxwsprj" already created.
Right click on the project "jaxwsprj".
New
Other
Click on the JSP File
Next
Name: WSClientJSP.jsp
Next
Finished
WSClientJSP.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page
import="java.net.URL,javax.xml.namespace.QName,javax.xml.ws.Service,com.vinod.webservicejaxws.GreetingWebService"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
URL url = new URL(
"http://localhost:8080/jaxwsprj/GreetingWebService?wsdl");
// argument first, refer from wsdl
// argument second, refer from wsdl
QName qname = new QName("http://webservicejaxws.vinod.com/",
"GreetingWebServiceImplService");
Service service = Service.create(url, qname);
GreetingWebService hello = service
.getPort(GreetingWebService.class);
out.println(hello.sayWelcome("Vinod"));
%>
</body>
</html>
Stop the tomcat instance if already running.
Export the WAR in Tomcat
Right click on the jaxwsprj project > Export > War file
Live the web project name as it is: jaxwsprj
Destination: \apache-tomcat-6.0.39\webapps\jaxwsprj.war
Start the tomcat from /tomcate/bin/startup.bat
Verify the service
Open the any browser and enter the URL
http://localhost:8080/jaxwsprj/WSClientJSP.jsp
Output:
Welcome Vinod !
Enjoy your day, with fun & learning!
No comments:
Post a Comment