Tuesday, 7 December 2010

Flex: Chimp security solution (use it without metadata on source code!!!)

"Chimp is permission based filtering component for Adobe Flex and AIR. Applications implement Chimp by adding metadata within the Flex UIComponents. Based on the metadata it will remove components completely, enable/disable, and update visibility."


In this post I will show you an extension for the Chimp component that will provide a transparent implementation of the security for the developers. With this extension the permissions metadata is no longer needed to be in the source code. The permissions will be loaded dynamically at runtime.


First of all, let me give you a short view of the architecture we are using in our applications:
- the main application navigation is made in a superTabNaviagtion: every conversartion (screen) is loaded in a separate tab.
This is done by the core of the architecture (our framework), every developer's team only have to take care of their conversations (screens), that will be loaded by the framework in a client workbench.

What I will do is, before every new screen (new tab) is loaded, I will call a service that will give the permissions (permitted actions) for that screen and then I will set those permissions to the Chimp component.

Of course, I will need a separate application to carry on those permissions actions of our components (that otherwise must to be written in the source code of the application as metadata), and this application will be managed by an administrator.

Finally, the only thing needed for working correctly is that every button or component to be securiced must have an unique id in the whole application. This could be done easily with naming conventions.

The next code is added to Chimp.as:
/**
* Load chimp before the UIComponents are added with permission strings
*/
public static function load(permissions:ArrayCollection, metadataPermissions:Boolean=true):void {
  if(permissions != null) {
    _permissions = permissions;
    _permissions.addEventListener(CollectionEvent.COLLECTION_CHANGE, updateDisplay);
  } else {
    permissions = new ArrayCollection();
  }
  _metadataPermissions= metadataPermissions;

  //add chmip system add handler  
  FlexGlobals.topLevelApplication.addEventListener(Event.ADDED_TO_STAGE, processComponenet, true);
}

/**
 * @author s2o
 * 
 * 
 *  
   
  
  
 
 * 
 * @param screenActions
 * 
 */
public static function addScreenPermissionActions( screenActions:XML ):void{
 var screenId:String = screenActions.@id;
 
 for each (var metadata:XML in screenActions.descendants("metadata")) {
  // the ChimpConstants.ACTION_REMOVE_CHILD is not considered
  var chimpAction:ChimpAction = getAction(metadata);
  chimpAction.parentId = screenId;
  ChimpActionCache.instance.addDelayLoadAction(chimpAction);
 }   
}

/**
 * @author s2o
 * 
 * Removes permission from cache    
 * @param screenId
 * 
 */
public static function removeScreenPermissionActions(screenId:String):void {
  ChimpActionCache.instance.freeCachedActionById(screenId);
}

//process ui object
private static function process(obj:Object):void {
 if(obj is UIComponent) {           
  if (_metadataPermissions) {
   processMetadataPermissions(obj);      
  } else {
   processDelayPermissions(obj);
  }
 }
}


/**
 * @author s2o
 *  
 * @param obj
 * 
 */
private static function processDelayPermissions(obj:Object):void {  
 var comp:UIComponent = obj as UIComponent;      
 for each(var delayedChimpAction:ChimpAction in ChimpActionCache.instance.getDelayLoadActionById(comp.id)) {
  delayedChimpAction.comp = comp;
  doAction(delayedChimpAction);
  // for updates display on changes to the roles
  ChimpActionCache.instance.addAction(delayedChimpAction);                                                       
 }   
}

Thursday, 2 September 2010

AndroMDA vs Acceleo (MDA)

Objective

The aim of this paper is a brief introduction to MDA technology and a summary / comparison to the approachments to MDA of AndroMDA and Acceleo, intending to be a practical and understandable summary

Introduction

Model-driven architecture (MDA) is a software design approach for the development of software systems. It provides a set of guidelines for the structuring of specifications, which are expressed as models. It was launched by the Object Management Group (OMG) in 2001

The Model-Driven Architecture approach defines system functionality using a platform-independent model (PIM) using an appropriate domain-specific language (DSL).

One of the main aims of the MDA is to separate design from architecture. As the concepts and technologies used to realize designs and the concepts and technologies used to realize architectures have changed at their own pace, decoupling them allows system developers to choose from the best and most fitting in both domains. The design addresses the functional (use case) requirements while architecture provides the infrastructure through which non-functional requirements like scalability, reliability and performance are realized. MDA envisages that the platform independent model (PIM), which represents a conceptual design realizing the functional requirements, will survive changes in realization technologies and software architectures.

To sum up:

  • Models are produced at business level, and translated into code using code generation tools
  • The skill to move from model to implementation reduces most of the coding efforts
  • By having the models in the first iteration of software construction, allows the possibility of obtaining an executable prototype system in early stages of project life cycle
  • The transformation's rules for going from model to code are common to all similar projects, therefore the same rules apply to any project developing software allows a consistent software related to its quality and use of standards
Pros of MDA:

  • Focus on the business
  • Updated documentation. The process is, first change the model and then, regenerate the code.
  • Less application errors: “The best way to avoid dangerous coding errors is to code less”
  • Portability of the technology: If there's a new technology, by updating the PSM we can generate the code in the new technology
Cons of MDA:

  • If we don't have code generated by the MDA, we can't apply MDA.
  • The creation of components for the code automation is very complex
  • Refactoring. A change in the model involves a change in the code, therefor the sincronization between the new code generted and the original code implemented by the developer is always a delicate step (despite having tools that facilitate this task, this step is always delicate).

ANDROMDA:

Creator: Matthias Bohlen
Current state of the project:

  • AndroMDA 3.3 ( 2009-04-02) is the latest stable release (only supports UML 1.x)
  • AndroMDA 3.4 -snapshot (2010-02-14) supports UML 2.x: all the modern versions of uml tools use UML 2.x
  • AndroMDA 4: is on hold
  • AndroMDA-eclipse plugin: seems to be hold, version 1.0-M3 since 2006

Features:

  1. Open source framework that receives as an input a UML model that combined with suitable cartridges AndroMDA (model for technology mapping. NET, J2EE …), generates the source.
  2. AndroMDA cartridges are developed in velocty template (http://velocity.apache.org/). AndroMDA comes with a series of cartridges for the comprehensive code generation: BPM4Struts, jBPM, JSF, EJB, EJB3, Hibernate, Java, Meta, Spring, WebService and Xmlschema
  3. The sincronice of the model and the code generated by AndroMDA is done by taking into account that the code generated by AndroMDA consists of final classes that can't be modified by developers and abstract classes / interfaces, on which the developer implements the logic of business.That is the strategy for code generation is the direct heritange and delegation, therefore we depend on the final language and on the language structures to be able to generate final code, complex or not.
  4. AndroMDA is integrated with maven, but not with eclipse. Therefore, the management of new projects and code's generation will be done through the command line or ant task. For implementing a project with AndroMDA, we'll subdivid into: a MDA project (where AndroMDA generates code from the model) and a Development Project (where development and testing take place).




Community support: AndroMDA has maybe, one of biggest community of a MDA framework



ACCELEO

Creator: Obeo
Current state of the project:


Features (Acceleo 3):

  1. Acceleo is an implementation of the Object Management Group (OMG) MOF Model to Text Language (MTL) standard. This component is an entirely new development of the OMG MOF Model to Text (Mof2Text) http://www.omg.org/spec/MOFM2T/1.0/ language. The implementation will be compliant
  2. The development of the code generation's modules is done by acceleo type projects in eclipse.There are currently very basic examples of code generation for Python and Java. In version 2 we can find more complex modules of generation. Acceleo focuses on supporting the creation of code generation, so it is really easy to create new modules: preview of the final result of the generation, debug, launch generation integrated in eclipse.
  3. The sincronization between the model and the code generated by Acceleo is done through special tag's (in the code generation templates) that shows the developer where to enter the specific new code. This makes that the final code generated by Acceleo can be very complex.. It could happened as well that a non-skillfull (clueless) developer removes special tags and then, the new code generated by Acceleo will not repect the code created by the developer.
  4. Code generation from a model and code generation module is done through an integrated implementation task in eclipse. And configured through a wizard of the eclipse. The implementation of an Acceleo project would be the usual with eclipse, because the generated code is integrated into the development of the developer.




Community support: it's not as big as AndroMDA's community, but I have to say that was great to make a question in its forum and have a quick reponse






That's all folks! 
Please if you see any incoherent, feel free to make corrections / suggestions.


Thursday, 8 April 2010

email: spring + velocity

One of the best ways to send e-mails is with spring and velocity template. With this technique sending an e-mail is as easy as make a jsp.

In this sample I'm integrating the spring & velocity with struts2 and portlets, but could be extrapolated to any other environment.

The recipe consists of:
- applicationContextBeans.xml -> the sprig config file (the glue)
- registrarse.vm -> a velocity template of our e-mail
- EmailService.java & EmailServiceImpl.java -> the classes to apply the data to the template and send the e-mail. These classes will be the same for all the e-mails, so could be in a separate jar.
- RegistrarseAction.java -> the struts2 action

-applicationContextBeans.xml:
<bean id="emaiInformacionlService" class="es.project.miGestion.administracionDatos.service.EmailServiceImpl" scope="prototype">
        <property name="velocityEngine" ref="velocityEngine"></property>
        <property name="velocityTpl" value="es/project/velocity/solicitudInformacion.vm"></property>
            <property name="inlineFiles">   
         <map>              
             <entry>  
                 <key>  
                     <value>id001</value>  
                 </key>  
                 <value>classpath:es/project/velocity/logoproject.png</value>  
             </entry>  
         </map>  
       </property>  
    </bean>
    <bean id="emailRegistrarseService" class="es.project.miGestion.administracionDatos.service.EmailServiceImpl" scope="prototype">
        <property name="velocityEngine" ref="velocityEngine"></property>
        <property name="velocityTpl" value="es/project/velocity/registrarse.vm"></property>
        <property name="inlineFiles">   
         <map>              
             <entry>  
                 <key>  
                     <value>id001</value>  
                 </key>  
                 <value>classpath:es/project/velocity/logoproject.png</value>  
             </entry>  
         </map>  
       </property>  
    </bean>

- registrarse.vm:
<div id="logo">
        <p align="right"><img src="cid:id001" /></p>
    </div>
    <div id="header">
        <font size="2" style="font-family: Arial; color: rgb(51, 90, 143);">
            A la Atenci&oacute;n del Servicio de Atenci&oacute;n Telef&oacute;nica
            <br><br>
            Cliente registrado en el formulario de la web. 
            #set ($bar = "cliente")
            #if (${cliente} == $bar)
                Ya es cliente de  project y desea que un comercial se encarge de darle de alta en la Web de  project:
            #else
                No es cliente de  project y desea que un comercial se encarge de darle de alta en la Web de  project:
            #end
        </font>
    </div>
    <br>
    <div id="content">
        <font size="2" style="font-family: Arial; color: rgb(51, 90, 143);">
            <table class="width100" border="0" cellspacing="0" cellpadding="0">    
                <tr>
                    <td style="font-size: 9pt; font-family: Arial; color: rgb(51, 90, 143);" width="110">Nombre</td>
                    <td style="font-size: 9pt; font-family: Arial; color: rgb(51, 90, 143);" >${nombre} ${apellidos}</td>
                </tr>
                <tr>
                    <td style="font-size: 9pt; font-family: Arial; color: rgb(51, 90, 143);" >DNI</td>
                    <td style="font-size: 9pt; font-family: Arial; color: rgb(51, 90, 143);" >${dni}</td>
                </tr>
                <tr>
                    <td style="font-size: 9pt; font-family: Arial; color: rgb(51, 90, 143);" >Direcci&oacute;n:</td>                
                    <td style="font-size: 9pt; font-family: Arial; color: rgb(51, 90, 143);" >${direccion},${cp} ${poblacion} - ${pais}</td>
                </tr>
                <tr>
                    <td style="font-size: 9pt; font-family: Arial; color: rgb(51, 90, 143);" >Telefono:</td>                
                    <td style="font-size: 9pt; font-family: Arial; color: rgb(51, 90, 143);" >${telefono}</td>
                </tr>
                <tr>
                    <td style="font-size: 9pt; font-family: Arial; color: rgb(51, 90, 143);" >Movil:</td>                
                    <td style="font-size: 9pt; font-family: Arial; color: rgb(51, 90, 143);" >${movil}</td>
                </tr>        
                <tr>
                    <td style="font-size: 9pt; font-family: Arial; color: rgb(51, 90, 143);" >Email:</td>                
                    <td style="font-size: 9pt; font-family: Arial; color: rgb(51, 90, 143);" >${mail}</td>
                </tr>    
                #if (${cliente} == $bar)        
                    <tr>
                        <td style="font-size: 9pt; font-family: Arial; color: rgb(51, 90, 143);" >N&uacute;mero cuenta:</td>                
                        <td style="font-size: 9pt; font-family: Arial; color: rgb(51, 90, 143);" >${numeroCuenta}</td>
                    </tr>    
                #end
            </table>
        </font>        
    </div>
    <br>
    <hr size="2" width="100%" align="left">
    <span style="font-size: 7.5pt; font-family: Arial; color: rgb(51, 90, 143);">
        .....
    </span>

- EmailServiceImpl.java
...
    private VelocityEngine velocityEngine;    
    private JavaMailSender javaMailSender;
    private String velocityTpl;
    
    private Map<String,Resource> inlineFiles;
    
    /**
     * Creaci�n y env�o de e-mail.
     * @param from E-mail de origen
     * @param recipients E-mails de destino
     * @param subject Asunto del e-mail
     * @param params Par�metros para la generaci�n del cuerpo del e-mail
     */
    public void sendEmail(String from, String[] recipients, String subject, Map<String,Object> params) {
        log.debug("sendEmail inicio");
        
        final String f = from;        
        final String s = subject;
        final Map<String,Object> p = params;
        
        for(final String to : recipients){
            MimeMessagePreparator preparator = new MimeMessagePreparator(){
                public void prepare(MimeMessage mimeMessage) throws Exception{
                    MimeMessageHelper helper = new MimeMessageHelper(mimeMessage,true);
                    helper.setFrom(f);
                    helper.setTo(to);
                    helper.setSubject(MimeUtility.encodeText(s, "iso-8859-1", "B"));                        
                    Map<String,Object> model = p;
                    String text = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine,velocityTpl,model);
                    helper.setText(text, true);
                    
                    // añadiendo los ficheros "en línea"
                    if (getInlineFiles() != null) {
                        for (String key :getInlineFiles().keySet()) {
                            Resource value = getInlineFiles().get(key);
                            helper.addInline(key, value);
                            if (log.isDebugEnabled()) {
                                log.debug("File '" + value + "' added.");
                            }
                        }
                    }
                }
            };
            javaMailSender.send(preparator);
        }
        
        log.debug("sendEmail fin");
    }
    
    /**
     * Create and setup the mail sender component
     *  @param mailTO

     */
    public void initializeJavaMailSender(MailTO mailTO){        
        log.debug("initializeJavaMailSender inicio");
        
        //Create and setup the mail sender component
        JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
        mailSender.setHost(mailTO.getHostMail());
        mailSender.setPort(Integer.valueOf(mailTO.getPort()));    
        mailSender.setUsername(mailTO.getUsername());    
        mailSender.setPassword(mailTO.getPassword());
        
        //We need this setting for force Javamail to pass the login
        boolean mailSmtpAuth = mailTO.getMailSmtpAuth().equals("true");
        boolean starttls = mailTO.getStarttls().equals("true");
        
        Properties props = new Properties();
        if(mailSmtpAuth){
            log.debug("mailSmtpAuth true:"+mailTO.getMailSmtpAuth());
            props.setProperty("mail.smtp.auth", mailTO.getMailSmtpAuth());
        }
        if(starttls){
            log.debug("starttls true:" + mailTO.getStarttls());
            props.setProperty("mail.smtp.starttls.enable", mailTO.getStarttls());
        }
        mailSender.setJavaMailProperties(props);
        
        javaMailSender = mailSender;            
        
        log.debug("initializeJavaMailSender fin");
    }
...

- RegistrarseAction.java
// Enviar los datos por mail
        emailRegistrarseService.initializeJavaMailSender(mailTO);
        
        String[] recipients = mailTO.getToMail().split(";");
        String[] emailUsuario = mail.split(";");

        Map<String, Object> params = new HashMap<String, Object>();
        params.put("cliente", cliente);
        params.put("nombre", nombre);
        params.put("apellidos", apellidos);
        params.put("dni", dni);
        params.put("direccion", direccion);
        params.put("poblacion", poblacion);
        params.put("mail", mail);
        params.put("telefono", telefono);
        params.put("pais", pais);
        params.put("cp", cp);
        params.put("movil", movil);
        params.put("numeroCuenta", numeroCuenta);

        emailRegistrarseService.sendEmail(mail, recipients, 
                mailTO.getSubject(), params);

Monday, 15 March 2010

Integrate struts2-jquery and portlets

In this FAQ we can see how to install the struts2-jquery plugin, but we have to make some little changes if we are developing porlets:

1.Add the next servlet-mapping to the web.xml file:
<servlet>
        <servlet-name>struts2servlet</servlet-name>
        <servlet-class>org.apache.struts2.dispatcher.ng.servlet.StrutsServlet</servlet-class>
</servlet>
<servlet-mapping>
        <servlet-name>struts2servlet</servlet-name>
        <url-pattern>*.action</url-pattern>
</servlet-mapping> 
<servlet>
        <servlet-name>struts2Resources</servlet-name>
        <servlet-class>org.apache.struts2.dispatcher.ng.servlet.StrutsServlet</servlet-class>
</servlet>
<servlet-mapping>
        <servlet-name>struts2Resources</servlet-name>
        <url-pattern>/struts/*</url-pattern>
</servlet-mapping> 

This could be done by a filter-mapping too, but with filter-mapping we can have some problems in a Websphere server.

2.Define some pakage in the struts2 config to manage the ajax request
<package name="ajax" extends="json-default" namespace="/ajax">
...
</package>

3.To make a valid ajax request from the portlet, all the request must be as the next examples:
<form id="compraVentaForm" action='<s:url value="/ajax/compraVentaSave.action"/>'  method="post">
...
</form>
<s:url id="ordenesActivasResultado" value="/ajax/ordenesActivas.action"/>
<sj:div href="%{ordenesActivasResultado}" indicator="indicator" onCompleteTopics="completeDiv" reloadTopics="reloadDiv">
 <img id="loading" src="<s:url value='/img/ajax-loader.gif'/>" alt="Loading..."/>
</sj:div>

Saturday, 27 February 2010

SAP Java Connector (SAP JCo) : sample

Here's a sample code to get the currency list of the BAPI ZBAPI_GET_CURRENCY_LIST:

ArrayList desMoneda = new ArrayList();
ArrayList ideMoneda = new ArrayList();

//Creamos la función de la BAPI
com.sap.mw.jco.JCO.Function funcionDivisas = repository.getFunctionTemplate("ZBAPI_GET_CURRENCY_LIST").getFunction();

//Declaramos los parámetros que se le enviarán a la BAPI
com.sap.mw.jco.JCO.ParameterList listParams = funcionDivisas.getImportParameterList();      
listParams.setValue("ES","LANGU");

//Ejecutamos la BAPI
connection.execute(funcionDivisas);

//Recuperamos la tabla de SAP
Table tablaDivisas = funcionDivisas.getTableParameterList().getTable("CURRENCYLIST");
desMoneda.add(Text.getText("language.messages", "ActividadRegistro.comboDivisa", oLocale));
ideMoneda.add("");

//Recorremos la tabla de divisas y seteamos los arrays del formulario
for (int i = 0; i < tablaDivisas.getNumRows(); i++){
 ideMoneda.add(tablaDivisas.getValue("WAERS"));
 desMoneda.add(tablaDivisas.getValue("LTEXT"));  
 tablaDivisas.nextRow();
}
And here's the connectSap() and disconnectSap() functions:
/** Conexion */
protected JCO.Client connection;   // Connection con SAP
/** Repositorio */
protected IRepository repository;   // Repostorio de funciones SAP

/**
 * Iniciamos la conexion y el repositorio con el SAP
 *
 */
public void connectSap(String client, String user, String pass, String lang, String host, String nSystem, String name) {
 try {
  /** Creamos la conexion con el SAP   */  
  connection = JCO.createClient(client, user, pass, lang, host, nSystem);
  connection.connect();

  /** Creamos el repositorio con el SAP   */
  repository = new JCO.Repository(name, connection);
 } catch(Exception e) {
  log.error("Error -> connectSAP: " + e.getMessage(),e); 
 }
}

public void disconnectSap() {
 if(connection != null) {
  try {
   connection.disconnect();
  }catch(Exception e) {
  log.error("Error -> disconnectSap: " + e.getMessage(),e);
  }
 }
}

Monday, 18 January 2010

WebService client: automating the generation of all java classes

The problem:
Sometimes when we have to make a webservice client, we have the wsdl definition file and we have to choose some tecnique to generate the java client classes. But after all the code generated automatically by the framework we have an xmlStream to treat with... So finally, we have to implement the model classes of the part of the xml that we're interested in.

To automate this final step we can generate the java classes to unmarshall the xml into java classes that matches data.

In my last project I had the requirement to do this with axis (Axis2) and xmlbeans (XMLBeans). The webService was a Sharepoint service: lists.asmx.

The solution:
Create an xml ant to transform the wsdl to java: wsdl2java-SharepointList.xml. And create another xml ant to transform the xml returned by the webService: buildSharepointListItems.xml

1.-wsdl2java-SharepointList.xml:
<!DOCTYPE project>

<project name="wsdl2java-WebXXXX_Service" default="usage" basedir=".">

<property name="project-name" value="XXXX.ws.XXXXNet"/>
<property name="definicionDelWebService" value="input/webXXXX_Service.wsdl"/>
<property name="packageDestino" value="es.XXXX.ws.XXXXNet"/>
<property file="build.properties"/>

<property name="build" value="build"/>
<property name="src" value="src"/>
<property name="build.classes" value="build/classes" />

<path id="axis.classpath">
<pathelement location="build/classes" />
<fileset dir="${axis.home}/lib">
<include name="**/*.jar" />
</fileset>
<fileset dir="${xmlBeans.home}/lib">
<include name="**/*.jar" />
</fileset>
<pathelement location="${build.classes}" />
</path>

<path id="axis_client.classpath">
<pathelement location="build/classes" />
<fileset dir="${axis.home}">
<include name="**/*.jar" />
</fileset>
<fileset dir="lib">
<include name="*.jar" />
</fileset>
<pathelement location="${build.classes}" />
</path>

<target name="usage" description="Build file usage info (default task)">
<echo message=" " />
<echo message="${project-name} " />
<echo message="-------------------------------------------------------" />
<echo message=" " />
<echo message="Available Targets:" />
<echo message=" Cleaning up:" />
<echo message="  clean             - Delete class files" />
<echo message=" " />
<echo message=" WSDL:" />
<echo message="  wsdl2java         - Generate source from WSDL" />
<echo message=" " />
<echo message=" Compiling:" />
<echo message="  compile           - Compiles the WSDL2Java source code" />
<echo message=" " />
<echo message=" jar final:" />
<echo message="  jar_wsdl          - Generate the jar from WSDL2Java source code" />
</target>

<target name="prepare" >
<mkdir dir="${build.classes}" />
</target>

<target name="clean" >
<delete dir="${build}" />
<delete dir="output" />
</target>

<target name="wsdl2java" depends="clean,prepare">
<java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true">
<classpath refid="axis.classpath"/>          
<arg value="-uri"/>
<arg file="${definicionDelWebService}"/>
<arg value="-o"/>
<arg file="output"/>
<arg value="-d"/>
<arg value="xmlbeans"/>
<arg value="-p"/>
<arg value="${packageDestino}"/>
<arg value="-s"/>
<arg value="-u"/>
</java>

<!-- Move the schema folder to classpath-->
<move todir="${build.classes}">
<fileset dir="output/resources">
<include name="**/*schema*/**/*.class"/>
<include name="**/*schema*/**/*.xsb"/>
</fileset>
</move>

</target>

<target name="compile">
<echo message="Compiling wsdl2 files"/>
<javac
       srcdir="output"
       destdir="${build.classes}"
       deprecation="true"
      source="1.5"
          target="1.5"
    failonerror="true" debug="false">
<classpath refid="axis.classpath"/> 
</javac>
</target>

<target name="jar_wsdl" depends="compile">
<jar jarfile="lib/${project-name}.jar" >
<fileset dir="${build.classes}" />
</jar>
</target>

<target name="all" depends="wsdl2java,jar_wsdl">
<echo message="Generando el jar desde el wsdl"/>
</target>
</project>


2.-buildSharepointListItems.xml:
<!DOCTYPE project>

<project name="buildSharepointListItems" default="usage" basedir=".">

 <property name="project-name" value="torres.ws.shareponint.listItems"/>
 <property name="xmlDeDatosInput" value="input/listItemsRetorn.xml"/>
 <property name="xmlDeDatos" value="listItemsRetorn"/>
 <property file="build.properties"/>

 <property name="build" value="build"/>
 <property name="src" value="src"/>
 <property name="build.classes" value="build/classes" />

 <path id="xmlBean.classpath">
  <pathelement location="build/classes" />
  <fileset dir="${xmlBeans.home}/lib">
   <include name="**/*.jar" />
  </fileset>
  <pathelement location="${build.classes}" />
 </path>

 <target name="usage" description="Build file usage info (default task)">
  <echo message=" " />
  <echo message="${project-name} " />
  <echo message="-------------------------------------------------------" />
  <echo message=" " />
  <echo message="Available Targets:" />
  <echo message=" Cleaning up:" />
  <echo message="  clean             - Delete class files" />
  <echo message=" " />
  <echo message=" returned XML:" />
  <echo message="  xml2xsd               - Generate xsd from xml" />  
  <echo message=" " />
  <echo message=" generate java binding:" />
  <echo message="  xsd2java           - Generate java from xsd" />  
  <echo message=" " />
  <echo message=" Compiling:" />
  <echo message="  compile           - Compiles the xsd2java source code" />
  <echo message=" " />
  <echo message=" jar final:" />
  <echo message="  exportJar               - Generate the from WSDL2Java source code" />
 </target>

 <target name="prepare" >
  <mkdir dir="${build.classes}" />
  <mkdir dir="output" />
  <mkdir dir="src" />
 </target>

 <target name="clean" >
  <delete dir="${build}" />
  <delete dir="output" />
  <delete dir="src" />
 </target>

 <target name="xml2xsd" depends="clean,prepare">
  <java classname="org.apache.xmlbeans.impl.inst2xsd.Inst2Xsd" fork="true">
   <classpath refid="xmlBean.classpath"/>
   <arg value="-design"/>
   <arg value="rd"/>
   <arg value="-outDir"/>
   <arg file="src"/>
   <arg value="-outPrefix"/>
   <arg value="${xmlDeDatos}"/>
   <arg value="${xmlDeDatosInput}"/>
  </java>
 </target>

 <target name="xsd2java">
  <java classname="org.apache.xmlbeans.impl.tool.SchemaCompiler" fork="true">
   <classpath refid="xmlBean.classpath"/>
   <arg value="-d"/>
   <arg file="output"/>
   <arg value="-javasource"/>
   <arg value="1.5"/>
   <arg value="-srconly"/>
   <arg file="src"/>
   <arg value="input/${xmlDeDatos}.xsdconfig"/>
  </java>
 </target>

 <target name="compile" depends="xsd2java">
  <echo message="Compiling files"/>
  <javac
       srcdir="output"
       destdir="${build.classes}"
       deprecation="true"
      source="1.5"
          target="1.5"
    failonerror="true" debug="false">
   <classpath refid="xmlBean.classpath"/>
  </javac>
   <!-- Move the schema folder to classpath-->
       <move todir="${build.classes}">
           <fileset dir="output">
               <include name="**/*schema*/**/*.class"/>
               <include name="**/*schema*/**/*.xsb"/>
           </fileset>
       </move>
 </target>

 <target name="exportJar" depends="compile">
  <jar jarfile="lib/${project-name}.jar" >
   <fileset dir="${build.classes}" />
  </jar>
 </target>

 <target name="all" depends="xml2xsd,exportJar">
  <echo message="Generando el jar desde el wsdl"/>
 </target>
</project>

3. And finally, the java that call the sharepoint service:

HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
auth.setUsername(username);
auth.setPassword(password);
auth.setDomain(domain);
auth.setHost(host);
auth.setRealm(realm);

// Ensure NTLM authentication used
List authPrefs = new ArrayList(1);
authPrefs.add(AuthPolicy.NTLM);
auth.setAuthSchemes(authPrefs);

// Get stub
ListsStub stub = new ListsStub(sharepoinService  + "_vti_bin/lists.asmx");

// Set authenticator
stub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth);
// Get request and execute

com.microsoft.schemas.sharepoint.soap.GetListItemsDocument getListItems112 =com.microsoft.schemas.sharepoint.soap.GetListItemsDocument.Factory.newInstance();
GetListItems listaInput = GetListItems.Factory.newInstance();
listaInput.setListName(laguajeList[0]);
getListItems112.setGetListItems(listaInput );

GetListItemsResponseDocument listaResultado = stub.getListItems(getListItems112);
GetListItemsResult result = listaResultado.getGetListItemsResponse().getGetListItemsResult();
String resultString = result.xmlText();
log.debug(resultString);

resultString = resultString.replaceFirst("http://schemas.microsoft.com/sharepoint/soap/", "http://XXXXX/sharepoint/listItems");      
ListitemsDocument root= ListitemsDocument.Factory.parse(resultString);
List lista = root.getListitems().getData().getRowList();