Saturday 31 March 2012

JSF2 CLIENT FOR AXIS 1.1 WEBSERVICE

JSF2 CLIENT FOR AXIS 1.1 WEBSERVICE


         Yesterday I tried to create webservice by using axis 1.1 in tomcat6. But I was not able to. I thought that the reason could be older version of AXIS 1.1. I read in web that though axis 2 is the current version, there are number of projects which are using AXIS1.1. Therefore I downloaded the latest version of axis 1.1 from apache axis 1.1 site. that version is  axis-bin-1_4. When I unzipped it I got axis-1_4 folder. Inside the folder I had

Inside the webapps folder  I had axis folder. I copied that axis folder to d:\tomcat6\webapps folder. I found that drop in deployment worked correctly.  My jsf 2 application also working in the same tomcat6. I got correct result as what I got yesterday with tomcat5 and jsf1.1. AXIS 1.1 is not obsolete.
  screen  shot is given below


code is given below,

view.xhtml
--------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
            xmlns:h="http://java.sun.com/jsf/html">
            

 <body          bgcolor="cyan">
   <h:form id="form1" >

       <h:selectOneMenu  id="operation"  value="#{backer.state}">

          <f:selectItem  itemLabel="kerala" itemValue="kerala"/>
          <f:selectItem  itemLabel="tamilnad" itemValue="tamilnad"/>
          <f:selectItem  itemLabel="karnataka" itemValue="karnataka"/>


       </h:selectOneMenu>


       <h:commandButton   id="button1"
                          action="#{backer.show}"
                          value="show" />

  <h:inputTextarea rows="20" cols="40" id="text4"  value="#{backer.result}" />

   </h:form>
  </body>
  </html>
****************************************************
//backer.java
-------------
package  mypack;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.*;
import javax.faces.event.*;
import  java.util.*;
@ManagedBean
@SessionScoped



public class backer implements  java.io.Serializable
{
String     result;

String    state;



 public   void    setState(String a)   { state=a;}

 public   void    setResult(String a)   { result=a;}



 public   String  getState()   { return   state; }

 public   String  getResult()   { return   result; }

    public   String   show()
   {
        tourjwshelper   bean1  =  new tourjwshelper();
        String r=bean1.getcities(state);

        setResult(r);
       return null;
   }
}
**************************************************
//tourjwshelper.java
package  mypack;

import java.net.*;
import java.util.*;
import javax.xml.rpc.ParameterMode;
import org.apache.axis.client.Service;
import org.apache.axis.client.Call;
import org.apache.axis.encoding.XMLType;

public class    tourjwshelper
{


   public   String    getcities(String s)
   {

        String   v="";


     try
     {                      
     System.out.println("Start");
     String s1="showcities";

     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/tourguide.jws");

     call.setTargetEndpointAddress(url);

     call.setOperationName(s1);
     call.addParameter("name",XMLType.XSD_STRING,ParameterMode.IN);
     call.setReturnType(XMLType.XSD_STRING);

     String   r = s;

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


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

          return   v;

   }

}

and the .jws  file is same as given in webservice previous post.