Rajesh Devadas, Nandhini
Arumugam & Sujata De
JSP is an extensible Web technology that uses template data, custom elements, scripting languages, and server-side Java objects to return dynamic content to a client.
Typically the template data is HTML or XML elements. As html/jsp files are autodeployed in Weblogic, just copy the .html/.jsp file into a directory which is already deployed in Weblogic.
Any Directory can be deployed under the Web Application Module provided it should be of the following format. For example, see the above mentioned HelloWorldServlet directory structure.
WEB-INF
Classes
Web.xml
*.html
*.jsp
You can directly access the html file using http://hostname:port/
For example
http://localhost:7001/TestHtmls/HelloWorld.htmlsample.jsp
<%@ page import="java.util.Date"%>
The current time is <%= new Date().toString() %>
Creating a Web service from a Java class file
Following the steps given below does creating a Web service from a Java class. Copy the myWebService.java into your directory and compile it.
myWebService.java
public class myWebService
{
public String sayHello(String name)
{
if(name==null)
return "Hello Guest";
else
return "Hello " + name;
}
}
The servicegen ant task will create myWebService.ear file that can be deployed into the Weblogic. Running the following Ant Task using the command "ant" from the command prompt.
build.xml
warName="myWAR.war"
contextURI="Web_services">
javaClassComponents="myWebService"
targetNamespace="http://www.bea.com/examples"
serviceName="TraderService"
serviceURI="/TraderService"
generateTypes="True"
expandMethods="True"
style="RPC">
Once myWebservice.ear is created, deploy it in Weblogic under Deployments->Applications. The URL for accessing this Webservice will be http://hostname:portname/servicename. For Example http://localhost:7001/myWebservice/myWebservice.
Note: The style="rpc" attribute specifies that the operations in the Web service are all RPC-oriented. If the operations in your Web service are document-oriented, specify style="document" and run the Antbuild.
Conclusion
The real value of Web services lies in the composition of a set of Web services, or what is commonly known as creating a 'flow'. To create a truly versatile business flow suited to every purpose of the target user, Web services have to be developed from various kinds of software components on various technologies, languages and platforms. The present work addresses the creation of a simple Web service from a variety of J2EE components.
About the Author
The authors are working as Software
Engineers with Hewlett-Packard India Software Operations Ltd., in Bangalore and
have expertise in the areas of Web services and other J2EE technologies.
.