Services | Updates | Contact
Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML
Open Source c++
During our professional experience we have had many problems in finding drivers for industrial control cards for not muc
 
Java String Occurrence in a String
In this program you will learn how to find the occurrence of a String in another String.
 
More Tutorials...


    Loan Information     Struts     Open Source

Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML

 
 
Web Services

 
Comments
 
 

 

WEBSERVICE USING APACHE AXIS  TUTORIAL-2   UNDERSTANDING APACHE AXIS  
(part-3) (published in DeveloperIQ..April,2004)(www.developeriq.com) R.S.RAMASWAMY(rs.ramaswamy@gmail.com)

DROP-IN DEPLOYMENT IN AXIS             

First and foremost, we need to install Axis1.1 for Windows, in our system.  The January 2004 issue of DeveloperIQ dealt with Apache and the CD also carried a lot of Apache software.  But ‘Axis1.1 for windows’ was missing there.  So, we have to download it from the Apache website (http://xml.apache.org).It has been installed as c:\axis11. (The unzipped folder is about 30MB.).   

 Secondly, we need tomcat4.1, for deploying axis.  (It has been given in the March-2003 CD of DeveloperIQ.) It has been installed as d:\tomcat41.

We will find a folder, named ‘axis’ in ‘c:\axis11\webapps’ directory.Copy this ‘axis’ folder to:  ‘d:\tomcat41\webapps’ directory.

We need ‘activation.jar’.  Copy activation.jar to:

d:\tomcat41\webapps\axis\web-inf\lib’

(tomcat4.1\common\lib)

 After completing these preliminary steps, we create ‘sqlaxisbean.java’ in c:\sam folder, as given. (If we carefully study the code for the ConsoleClient, jsp and this bean, we will find that all of them are similar.) 

//  sqlaxisbean.java

import java.sql.*;

import java.util.*;

import javax.ejb.*;

import javax.naming.*;

import java.rmi.*; 

public class  sqlaxisbean

{ 

String   a;

  public   sqlaxisbean()

  { 

  a=""; 

  } 

  public String callejb(String s)

  {    

     try

    {

    Properties       props=new Properties();

    props.put

    (Context.INITIAL_CONTEXT_FACTORY,

             "weblogic.jndi.WLInitialContextFactory");

    String url="t3://127.0.0.1:7001";

    props.put(Context.PROVIDER_URL,url); 

    Context context=new InitialContext(props);

System.out.println("context ok..");

    sqlhome home=(sqlhome)context.lookup("sqlejbJndi");

System.out.println("home ok.."); 

    sqlremote remote=home.create();

System.out.println("remote ok.."); 

    a=remote.showdata(s);

    System.out.println(a);

        }catch(Exception e1)

        {System.out.println(" "+e1);} 

     return a;

  } 

 As we are now studying ‘Drop-in Deployment’, we just copy this source file’ into: ‘d:\tomcat41\webapps\axis’ folder as ‘sqlaxisClient.jws’ Carefully note that we have changed the file extension from *.java to   *.jws.

Let us now start tomcat4.1 as follows:

d:\tomcat41\bin>set JAVA_HOME=D:\JDK141

d:\tomcat41\bin>

set path=c:\windows\command;d:\jdk141\bin; 

d:\tomcat41\bin>startup

After the tomcat server is fully started (you get the messages as ‘jk running’) we can test out Axis installation over tomcat as follows: Start the browser and type the URL as:‘http://localhost:8080/axis/index.html’.We get the Axis welcome page:

If we type the URL as:‘http://localhost:8080/axis/AxisServlet’, we get another page saying:    ‘there is a webservice here’.After satisfying ourselves that things are alright, we type the URL as: ‘http://localhost:8080/axis/sqlaxisbean.jws’.  We get a link and when we click on this link, we get a wsdl file automatically generated. This is an XML file.  Search this file to checkup whether the name of our method, namely ‘callejb’ occurs there.  It will be there! So, our ejb axis service is up and running. It is now time to create a simple Console-Client in java to satisfy ourselves that our ejb is really available to be accessed by using the wsdl file.

 So, we now create the Console-Client for the webservice as shown.

//  sqlaxisbeanClient.java

import java.net.*;

import javax.xml.rpc.ParameterMode;

import org.apache.axis.client.Service;

import org.apache.axis.client.Call;

import org.apache.axis.encoding.XMLType;

import javax.xml.namespace.QName; 

public class sqlaxisbeanClient

{ 

   public static void main(String args[])

   {

     try

     {

     System.out.println("Start"); 

     Service   service=        new Service(); 

     System.out.println("Service ready"); 

     Call      call= (Call)service.createCall(); 

     System.out.println("call ready"); 

     URL       url=new  URL("http://localhost:8080/axis/sqlaxisbean.jws");

     call.setTargetEndpointAddress(url); 

     call.setOperationName("callejb");     

     call.addParameter("something", XMLType.XSD_STRING,ParameterMode.IN); 

     call.setReturnType(XMLType.XSD_STRING); 

     String   r   =  (String)call.invoke(new Object[]{args[0]}); 

     System.out.println(r);              

     }

    catch(Exception e1){System.out.println(""+e1);}

   }

} 

 

We have to set correct classpath for the window to include a number of files required for Axis.As it will be tedious to type it every time, we have created a batch file named ‘setcpath.bat’. Please note that it should be typed in a single line continuously as given.           

//   setcpath.bat

 set  classpath=c:\sam;     d:\bea\weblogic700\lib\weblogic.jar;

c:\axis11\lib\axis.jar;

c:\axis11\lib\jaxrpc.jar;

c:\axis11\lib\saaj.jar;

c:\axis11\lib\commons-logging.jar;

c:\axis11\lib\commons-discovery.jar;

c:\axis11\lib\wsdl4j.jar;

c:\tomcat4.1\common\lib\activation.jar;

c:\tomcat4.1\common\lib\xerces.jar     

After creating this file, we can simply type at the prompt,sam> setcpath. This will create the correct classpath for the working window.  We will now be able to compile jwsclient.java. After compiling, we can execute the program:>java jwsclient “select * from table1”. We will get names and numbers.  This was tested and found to be ok.Thus, we have developed and ejb, and accessed it as an xml webservice!

 In the next article of this seven-part tutorial, we will take up the wsdd method.  Continued in axis2d.htm 

visit  http://in.geocities.com/rsramsam

Facing Programming Problem?
Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

0 comments so far (post your own) View All Comments Latest 10 Comments:

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2007. All rights reserved.