Home Webservices WEBSERVICE USING APACHE AXIS TUTORIAL-1
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

WEBSERVICE USING APACHE AXIS TUTORIAL-1

Advertisement
Inter-operability is one of the two aims of Xml-webservice paradigm,while the other aim is tackling the firewall problem. (Since ASP.net runs only in Win2000, switch over to Win2000. before beginning this experiment).The emphasis is on the procedure, in l

WEBSERVICE USING APACHE AXIS TUTORIAL-1
Using Java XML-WEBSERVICE  from ASP.net.
( published in DeveloperIQ   January-2004)( www.developeriq.com)
R.S.RAMASWAMY (rs.ramaswamy@gmail.com) 

Sri.Manoj Kothale, has written a fine piece in DeveloperIQ(Nov'03) on  exposing an EJB as an XML-WebService, using Axis and JBOss. In this experiment, we attempt  exposing a javabean (jws)  from Tomcat/Axis and consuming that service in an ASP.net program.This is much simpler.

Inter-operability is one of the two aims of Xml-webservice paradigm,while the other aim is tackling the firewall problem. (Since ASP.net runs only in Win2000, switch over to Win2000. before beginning this experiment).The emphasis is on the procedure, in laboratory experiment fashion).

Kindly , ensure that correct versions of software , are used, as mentioned.It is presumed that DotNet SDK has already been installed and tested,for running asp.net programs.

   1)  axis1.1   was installed in c:\axis11

   2)  tomcat4.1  from march-2003 issue of Dev IQ.

                 was installed as c:\tomcat41 

   3)  We will  find a folder named 'axis' in c:\axiss11\webapps.

       Copy this ('axis') folder to  c:\tomcat41\webapps  folder.

   4)    We must copy  activation.jar  to:

          c:\tomcat41\webapps\axis\web-inf\lib   folder. (This file is available in jboss3.2\server\all\lib  folder

         and jboss3.2 was given in NovemberCD.)

       5)  We set JAVA_HOME  for tomcat as follows:

       c:\tomcat41\bin>set JAVA_HOME=D:\jdk141   (because, we have installed jdk1.4.1 in D-drive).

    6) We should uncomment the 'admin servlet' part in

      the web.xml  file in c:\tomcat41\webapps\axis\web-inf folder.

   7) We start tomcat server:

      c:\tomcat41\bin>startup

      8) This starts tomcat4.1 and we wait till, it is fully started.

    9) We create our own folder c:\axisdemo

      In this folder, we create a simple javabean   greeter.java   as given below. 

     //  c:\axisdemo\greeter.java 

       public class greeter

       {

          public String greetme(String s)

            {

             return "How are you???????.."+s;

            }

       }

   10) we copy  greeter.java as greeter.jws

       into           c:\tomcat41\webapps\axis    folder.

      (we did this while tomcat41 was running!).No problem!

    11)  We start the browser and type the URL as:              

           'http://localhost:8080/axis/greeter.jws' 

           and we get  a link to the wsdl file for the above service. When we click this link, we get a wsdl file .

           (wsdl -> webservice description language).

     12) We save this   wsdl file  in  d:\inetpub\wwwroot  folder   as greeter.wsdl

     13)    Our aim is to create a C# file from this wsdl file.

          The following command does that. 

         d:\inetpub\wwwroot>wsdl   greeter.wsdl 

         This command created  greeterService.cs  file! 

         ( carefully note that the name has been appended with  'Service')   

         The next step is to compile this source file into a dll.   

    14)..wwwroot>csc /t:library  

              /r:System.dll,System.Web.Services.dll,System.Xml.dll

               greeterService.cs

           (type this in continuous line).  

          ( t -> target   &  r -> reference)   

         This command created greeterService.dll 

    15) Now copy this dll file to  d:\inetpub\wwwroot\bin  folder.

   ( If there is no such 'bin' folder  create it.).

    Now create  greeterService.aspx  as given below.

    ( in d:\inetpub\wwwroot    folder)

<%@ page language="c#" %>

<script runat=server>

public void job1(Object o, EventArgs e)

{

    String  a = text1.Text; 

    greeterService   greeter = new greeterService(); 

    String  s = greeter.greetme(a); 

     Response.Write(s); 

} 

</script>

<html>

<body>

<form              runat=server>

  <asp:Textbox   id=?text1?                runat=server  />

  <asp:Button  onclick=job1  text="Click" runat=server   />

</form>

</body>

</html>

 ( Normally, IIS-5 will be running . If not, start it.)

 After this, type the URL in browser as: 

    'http://localhost/greeterService.aspx' 

    Remember that the tomcat server is running and supplying   the 'greeter.jws'.

After some delay ( due to compiling time), we get a form.Type your name in the textbox ( say, ?sam? )& click the button  to    invoke the service.  We get  'How are you??..sam?  message from the java web service. We get correct result .     We can also create a standalone C# client by just appending a main() to the greeterService.cs and naming it as  ?greeterConsole.cs?.

Ref:  AXIS..by RominIrani & JeelaniBasha (wrox press).  Tutorual-2  continues in axis2a.htm

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

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 13, 2008

Related Tutorials

Ask Questions?    Discuss: WEBSERVICE USING APACHE AXIS TUTORIAL-1   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com