WEBSERVICE USING APACHE AXIS TUTORIAL-2

WEBSERVICE USING APACHE AXIS TUTORIAL-2

WEBSERVICE USING APACHE AXIS TUTORIAL-2

WEBSERVICE USING APACHE AXIS TUTORIAL-2
Accessing ejb-webservice  using  WAP (Wireles-Application Protocol)
R.S.RAMASWAMY ([email protected])

c:\sam> edit ejbaxiswapservlet.java

******************************************

//ejbaxiswapservlet.java

----------------------

import java.net.URL;

import org.apache.axis.client.Service;

import org.apache.axis.client.Call;

import org.apache.axis.encoding.XMLType;

import javax.xml.rpc.ParameterMode;

import javax.xml.namespace.QName;

import javax.servlet.*;

import javax.servlet.http.*;

import java.io.*;

public class ejbaxiswapservlet extends HttpServlet

{

    public void doPost (HttpServletRequest request,  

                        HttpServletResponse response)

                 throws ServletException, IOException

    {

      response.setContentType("text/vnd.wap.wml");

        PrintWriter out = response.getWriter();

        String sql = request.getParameter("text1");

        try{

            String url = "http://localhost:8080/axis/services/sqlservice";

            String method = "getdata";

            Service   service = new Service();

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

      call.setTargetEndpointAddress ( url);

      call.setOperationName 0

             ( new QName("sqlservice",method));

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

    call.setReturnType(XMLType.XSD_STRING); 1

            System.out.println("Call Ok");

  Object[] params = new Object[] { args[0] };

       System.out.println("Params ok..."); 2

     String s = (String) call.invoke(params);

         System.out.println(s);

      out.println("<p>"); 3

      out.println("ejb with wap<br/>");

      out.println(s);

      out.println("</p>"); 4

      out.println("</card>");

      out.println("</wml>");

        }catch(Exception e) 5

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

    }

} 6

********************************************

Complie and copy  the class file to  tomcat as below.

  7

c:\sam> javac ejbaxiswapservlet.java 

copy c:\sam\ejbaxiswapservlet.class  to

     d:\tomcat 4.1\webapps\axis\web-inf\classes 8

Edit web.xml in 

  d:\tomcat 4.1\webapps\axis\web-inf folder 

      <servlet> 9

     <servlet-name>

        ejbaxiswapservlet

       </servlet-name> 0

     <servlet-class>

     ejbaxiswapservlet

     </servlet-class> 1

     </servlet>

     <servlet-mapping>

<servlet-name> 2

ejbaxiswapservlet

</servlet-name>

<url-pattern> 3

     \servlet\ejbaxiswapservlet

 </url-pattern>

     </servlet-mapping> 4

For accessing servlet, create a wml file in the working folder

and copy the file to

d:\tomcat 4.1\webapps\axis 5

c:\sam> edit ejbaxiswapservlet.wml

***************************************************

ejbaxiswapservlet.wml 6

---------------------

<?xml version="1.0"?>

<!DOCTYPE wml PUBLIC 7

 "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>

   <card id="card1"> 8

     <p>      

Query? <input type="text"  name="text1"   />  

   <do   type="accept"> 9

   <go  method="post" href="http://localhost:8080/axis/servlet/ejbaxiswapservlet"> 

           <postfield name="text1"  value="$text1"/>

   </go> 0

   </do>

   </p>            

   </card> 1

</wml>

*************************************************

Open 'Microsoft Mobile browser'and type the url as 2

'http://localhost:8080/axis/ejbaxiswapservlet.wml'

Make sure that tomcat is running. Enter sql query in the text box and submit it. we'll get the resultset as per the query. But, WAP is no-longer, the favoured wireless client because of limited functionality. Color graphics, games and animations are expected today. 

J2ME is the best solution for such apps, because,it is platform independent. 3

We now demonstrate how we can access an ejb-webservice from a j2me wireless client.( continued in axis3-3.htm

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

Tutorials

  1. Apache Axis2 - Apache Axis2 Tutorial
  2. Why Web Services?
  3. Java Building a Simple Web Service ? A Tutorial Tutorial
  4. Apache Geronimo Application server Tutorial
  5. Apache Axis2 Tutorial, Develop the Next Generation of Apache Web Services using Apache Axis2
  6. SOA and Web Services
  7. Web Services Examples in NetBeans
  8. SOA and Web Services
  9. J2EE Web Service Development with Attachments Using Axis
  10. J2EE Web Service Development with Attachments Using Axis
  11. WEBSERVICE USING APACHE AXIS TUTORIAL-2 UNDERSTANDING APACHE AXIS
  12. Web Services - Web Services Tutorials
  13. Developing Axis Web services with XML Schemas.
  14. What is Service-Oriented Architecture?
  15. WEBSERVICE USING APACHE AXIS -TUTORIAL-2 UNDERSTANDING APACHE AXIS
  16. WEBSERVICE USING APACHE AXIS TUTORIAL-2 UNDERSTANDING APACHE AXIS (part-2)
  17. WEBSERVICE USING APACHE AXIS TUTORIAL-1
  18. WEBSERVICE USING APACHE AXIS TUTORIAL-2 UNDERSTANDING APACHE AXIS
  19. WEBSERVICE USING APACHE AXIS - TUTORIAL-2 AXIS FOR EJB-WEBSERVICE (part-5)
  20. Web Services Tutorials and Links
  21. WEBSERVICE USING APACHE AXIS TUTORIAL-2
  22. WEBSERVICE USING APACHE AXIS- TUTORIAL-2 J2ME CLIENT FOR EJB & EJB-WEBSERVICE
  23. Web Service
  24. Java Client webservice
  25. Ejb Webservice
  26. SOAP with Attachments API for Java
  27. SOAP Header
  28. WSDL program
  29. Application Using JAX-RPC
  30. Security in Web Service
  31. JAX-RPC Advance Concepts
  32. Database driven webservices
  33. Apache Axis2 - Apache Axis2 Tutorial
  34. Apache Axis2 Introduction
  35. Downloading and Installing Apache Axis2
  36. Apache Axis2 Hello World Example
  37. Axis2 client - Axis2 Client example
  38. Axis2 ant wsdl2java - Learn WSDL2java utility of Axis2 with example
  39. Axis2 Eclipse plugin Tutorial
  40. Installing axis2 eclipse plugin