Web Services
  Home arrow Web Services arrow Page 4 - An Introduction to Web Services
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Moblin 
JMSL Numerical Library 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WEB SERVICES

An Introduction to Web Services
By: Mamun Zaman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 4
    2007-05-30

    Table of Contents:
  • An Introduction to Web Services
  • A closer look at SOAP, WSDL and UDDI
  • Web Services Development and Deployment
  • Getting to Work

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    An Introduction to Web Services - Getting to Work


    (Page 4 of 4 )

    You now have all necessary tool/software installed and ready. You have to create an interface for your web service. We are going to develop a web service that has just one function: the addition of two integers. The interface should look like the one below.

    public interface addWS {
      
    int add(int a, int b);
    }

    We have one function called add that takes two integers as parameters and returns an integer. Now we need to compile this into .class.

    Create WSDL from the Java Interface. AXIS comes into action for the first time here. We will use one tool that comes with AXIS -- Java2WSDL, for creating WSDL files from Java interfaces (to do this you don't need any knowledge of WSDL!). Use the following command to create the WSDL.

    java org.apache.axis.wsdl.Java2WSDL -o add.wsdl -l"http://localhost:8888/axis/service/add" addWS

    Here,org.apache.axis.wsdl.Java2WSDL is the main class, -o defines the output WSDL file name (add.wsdl), -l is used for the URL you would use to locate your service, and finally the interface class (without the .class extension). I assume you are in the folder where the interface class resides.

    Create Java Classes from WSDL. At first it may seem a bit confusing as we just created a WSDL from Java. For sending and receiving SOAP messages you need to use RPC, XML, HttpRequest and HttpResponse in a very complex way. We want AXIS to do this for us. If we use the WSDL2Java tool then AXIS will create all necessary classes for us for XML-RPC and others.

    java org.apache.axis.wsdl.WSDL2Java -o . -d Session -s -p addService add.wsdl

    Here, -o as usual is the location of the output directory (.), -d defines it as session meaning your Java classes will be created for each session (other values for -d are Application and Request), and -p defines the output package name.

    Modify the Java Classes. After creating all the classes from WSDL, we need to implement the interface we created earlier. Actually WSDL2Java creates a Java class called XXXSoapBindingImpl.java (XXX represents the service name) implementing the interface already described. We just need to put the logic into this class.

    Create Jar. Create a .jar archive file including all these classes and copy it into the lib folder of axis. The location usually is $TOMCAT_HOME/webapps/axis/WEB-INF/lib. Use the jar command - jar cvf filename.jar folder_to_jar.

    Deploy the Web Service using WSDD (Web Services Deployment Descriptor). When we used WSDL2Java, with all the Java classes two .wsdd files are also created. One is deploy.wsdd and the other is undeploy.wsdd. These descriptors are used for deploying and undeploying web services accordingly. Use the command shown below to deploy the service. You may need to restart Tomcat for completing the deployment.

    For deploying your service, go to the folder where your deploy.wsdd file is. Then issue the following command.

    java org.apache.axis.client.AdminClient -l http://localhost:8888/axis/services/AdminService deploy.wsdd

    Here, http://localhost:8888/axis/services/AdminService link locates the AdminService of AXIS as described earlier. To find the link click the AdminService link from AXIS list. You will get a page similar like the below. The link for AdminService is without the ?wsdl part of the address shown.

    After deployment your service will be displayed in AXIS list link.

    We have completed the development and deployment of web services using Apache AXIS. This way of developing web services is very simple, but if you want an even simpler way than this you can use the Netbeans IDE. The Netbeans IDE lets you develop web services by merely dragging and dropping.

    We talked mainly about creating and deploying web services in this article. I tried to focus on all the areas of developing web services using Java technology with AXIS. In the future I will describe how to create a web service client in PHP, .NET and Java, if you want. To learn more about Apache AXIS and the tools mentioned here please visit the Apache web site for AXIS at http://ws.apache.org/.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Very Good Article for Beginners who start learning Web ServicesThanks
     

    WEB SERVICES ARTICLES

    - Getting Started with Flex
    - Automated Billing and Faxing for the Web
    - An Introduction to Web Services
    - The Foundations of Web Services: From Novice...
    - Web Services Reengineering: Finishing Touches
    - Fault Handling with Web Services
    - Flow and Web Services
    - Process Lifecycles and Web Services
    - Business Processes and Web Services
    - Orchestrating Web Services
    - Notifications and Resources in the WS-Resour...
    - WS Notification and WS Topics in the WS Reso...
    - Introducing the Implied Resource Pattern
    - Web Services and Stateful Resources
    - Deploying an EJB Application






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
    Stay green...Green IT