Sunday, November 27, 2005

tomcat users

Man have I stubled on this one about a hundred times.

<?xml version='1.0' encoding='utf-8'?>

<tomcat-users>

<role rolename="manager"/>

<role rolename="tomcat"/>

<role rolename="role1"/>

<user username="admin" password="secret" roles="manager"/>

<user username="tomcat" password="tomcat" roles="tomcat"/>

<user username="role1" password="tomcat" roles="role1"/>

<user username="both" password="tomcat" roles="tomcat,role1"/>

</tomcat-users>

Friday, October 14, 2005

example of common use of web application context with struts

<!—web.xml -->

<web-app>

<display-name>Config Filter Application</display-name>

<context-param>

<param-name>contextConfigLocation</param-name>

<param-value>/WEB-INF/webContext-hibernate.xml</param-value>

</context-param>

<servlet>

<servlet-name>SpringContextServlet</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Standard Action Servlet Configuration (with debugging) -->

<servlet>
<servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>

<param-name>config</param-name>

<param-value>/WEB-INF/struts-config.xml</param-value>

</init-param>

<init-param>

<param-name>debug</param-name>

<param-value>2</param-value>

</init-param>

<init-param>

<param-name>detail</param-name>

<param-value>2</param-value>

</init-param>

<load-on-startup>2</load-on-startup>

</servlet>

<!-- Standard Action Servlet Mapping -->

<servlet-mapping>

<servlet-name>action</servlet-name>

<url-pattern>*.do</url-pattern>

</servlet-mapping>

<!-- The Usual Welcome File List -->

<welcome-file-list>

<welcome-file>index.jsp</welcome-file>

</welcome-file-list>

<!-- Struts Tag Library Descriptors -->

<taglib>

<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>

<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>

</taglib>

<taglib>

<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>

<taglib-location>/WEB-INF/struts-html.tld</taglib-location>

</taglib>

<taglib>

<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>

<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>

</taglib>

<taglib>

<taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri>

<taglib-location>/WEB-INF/struts-nested.tld</taglib-location>

</taglib>

<taglib>

<taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>

<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>

</taglib>

<taglib>

<taglib-uri>/WEB-INF/c.tld</taglib-uri>

<taglib-location>/WEB-INF/c.tld</taglib-location>

</taglib>


</web-app>

//ACTION BASE CLASS

import javax.servlet.ServletContext;
import org.apache.struts.action.Action;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

public abstract class SpringBeanAccessorAction extends Action {

/** To be cast by client
*/

protected Object makeBLServiceBean(String name)
{

ServletContext servletContext = this.servlet.getServletContext();
WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
Object blservice = context.getBean(name);
return blservice;

}

}

Tuesday, October 11, 2005

simple ant project


<project basedir="." default= "web-war" name="contextuon">
<target name="init">
<property name="name" value="contextuon">
<property name="src.dir" value="src">
<property name="dist.dir" value="dist">
<property name="deploy.dir" value="C:/jboss-4.0.1sp1/server/default/deploy">
<property name="web.dir" value="web">
<property name="project.lib" value="lib">
<property name="build.dir" value="build">
<property name="config.dir" value="config">
<property name="build.compiler" value="modern">

<!-- jdbc -->
<property name="jdbc.url" value="jdbc:postgresql://pathfinder/amo">
<property name="database.driver" value="org.postgresql.Driver">
<property name="database.username" value="avexnet">
<property name="database.password" value="avexnet">
<property name="database.schema" value="">
<property name="database.catalog" value="">


<!--war info-->
<property name="build.dir.web" value="${build.dir}/web">
<property name="build.web.inf" value="${build.dir.web}/WEB-INF">
<property name="build.web.classes" value="${build.web.inf}/classes">

<property name="warfile" value="${name}.war">
<property name="web.orig.dir" value="web">
<property name="web.lib" value="${web.orig.dir}/WEB-INF/lib">
<property name="web.classes" value="${web.orig.dir}/WEB-INF/classes">

<!--javadoclet properties-->
<property name="javadoc.dir" value="${web.orig.dir}/html/docs">



<!-- Configure the custom Ant tasks for the Manager application -->
<echo message="JAVA_HOME=${java.home}">
<mkdir dir="${dist.dir}">

 <path id="project.class.path">
<fileset dir="${java.home}/lib">
<include name="*.jar">
</fileset>
<fileset dir="${project.lib}">
<include name="*.jar">
</fileset>
<fileset dir="${web.lib}">
<include name="*.jar">
</fileset>
<fileset dir="${dist.dir}">
<include name="*.jar">
</fileset>
</path>

<tstamp>
<format pattern="d-MM-yy" property="TODAY">
</tstamp>


</target>

<target name="prepare" depends="init"
description="Create build directories.">
<mkdir dir="${dist.dir}">
<mkdir dir="${build.dir}">
<mkdir dir="${build.web.classes}">
<mkdir dir="${build.dir.web}/WEB-INF">
<mkdir dir="${build.dir.web}/WEB-INF/lib">
<mkdir dir="${build.dir.web}/html">
<mkdir dir="${build.dir.web}/images">
<mkdir dir="${build.dir.web}/js">
</target>


<target name="hibernate-gui" depends="init, prepare" description="Runs hibernate ide">
<java classname="net.sf.hibern8ide.Hibern8IDE"
fork="yes" spawn="no">
<classpath refid="project.class.path">
<classpath>
<pathelement location="dist/${name}.jar">
</classpath>
</java>
</target>


<target name="jar-all" depends="init, prepare, web-compile">
<copy todir="${build.dir}/web/WEB-INF/classes">
<fileset dir="web/WEB-INF/classes">
<include name="**/*.lcf">
<include name="**/*.xml">
<include name="**/*.properties">
</fileset>
</copy>
<copy todir="${build.dir}/web/WEB-INF/classes">
<fileset dir="src">
<include name="**/*.properties">
<include name="**/*.hbm.xml">
</fileset>
</copy>
<jar jarfile="${dist.dir}/${name}.jar">
<fileset dir="${build.dir}/web/WEB-INF/classes" includes="**/*.class">
<fileset dir="${build.dir}/web/WEB-INF/classes" includes="**/*.xml">
<fileset dir="${build.dir}/web/WEB-INF/classes" includes="**/*.lcf">
<fileset dir="${build.dir}/web/WEB-INF/classes" includes="**/*.properties">
<fileset dir="${build.dir}" includes="META-INF/**">
</jar>
</target>


<target name="javadoc" depends="init, prepare">
<javadoc destdir="${javadoc.dir}" classpath="project.class.path" additionalparam="-tag ejb:X">
<fileset dir="${src.dir}">
<include name="**/*.java">
</fileset>
</javadoc>
</target>


<target name="web-compile" depends="init, prepare" description="Compile webapp Java files and copy HTML and JSP pages">
<javac deprecation="on" destdir="${build.web.classes}" srcdir="${src.dir}">
<include name="**/*.java">
<classpath refid="project.class.path">
</javac>
</target>

 <target name="web-war" depends="init, prepare, web-compile"
description="Compile app Java files and copy HTML and JSP pages" >

<copy todir="${build.dir.web}">
<fileset dir="${web.dir}">
<include name="**/*.*">
<exclude name="${web.dir}/WEB-INF/web.xml">
</fileset>
</copy>
<copy todir="${build.dir.web}/WEB-INF/classes">
<fileset dir="${src.dir}">
<include name="**/*.*">
<exclude name="**/*.java">
</fileset>
</copy>

<war warfile="${dist.dir}/${name}.war" webxml="${web.orig.dir}/WEB-INF/web.xml">
<fileset dir="${build.dir.web}">
<include name="**/*.*">
<exclude name="**/web.xml">
</fileset>
</war>
</target>

   <target name="all" depends="init, prepare, web-war" description="Compile webapp Java files and copy HTML and JSP pages">

<target name="deploy" depends="init, prepare, web-war">
<copy todir="${deploy.dir}">
<fileset dir="${dist.dir}">
<include name="${name}.war">
</fileset>
</copy>
</target>

<target name="clean" depends="init">
<delete dir="${build.dir}">
<delete dir="${generated.src.dir}">
<delete dir="${dist.dir}">
</target>

</project>

Wednesday, October 05, 2005

Tomcat 5 as an NT Service

This really should be much easier than it is, if you fail to update the VM options the thing fails, after a day of work the following example is the only one that worked for me.

install.bat

set JAVA_HOME=C:\j2sdk1.4.2_06
set CATALINA_HOME=c:\tomcat5
set CATALINA_BASE=c:\tomcat5
set EXECUTABLE=tomcat5.exe
set SERVICE_NAME=tomcat5server
set PR_STDOUTPUT=%CATALINA_HOME%\logs\stdout.log
set PR_STDERROR=%CATALINA_HOME%\logs\stderr.log

"%EXECUTABLE%" //IS//%SERVICE_NAME%
--DisplayName=cipc --Install="%CATALINA_HOME%\bin\tomcat5.exe"
--Jvm=auto
--JvmMs=128
--JvmMx=512
--StartMode=jvm
--Classpath="%CATALINA_HOME%\bin\bootstrap.jar;%CATALINA_HOME%\bin\servlet.jar;%JAVA_HOME%\lib\tools.jar"
--StopMode=jvm
--StartClass=org.apache.catalina.startup.Bootstrap
--StartParams=start
--StopClass=org.apache.catalina.startup.Bootstrap
--StopParams=stop

"%EXECUTABLE%" //US//"%SERVICE_NAME%"
--JvmOptions "-Xms128M;-Xmx512M;-Dcatalina.base=%CATALINA_BASE%;-Dcatalina.home=%CATALINA_HOME%;-Djava.endorsed.dirs=%CATALINA_HOME%\common\endorsed"
--StartMode jvm
--StopMode jvm

"%EXECUTABLE%" //US//"%SERVICE_NAME%"
++JvmOptions "-Djava.io.tmpdir=%CATALINA_BASE%\temp"
--JvmMs 128
--JvmMx 512

Tuesday, January 04, 2005

[cookbook] basic authorization of web services

Web services can use the common security realms to support per unit call authorization
support. This behaves identically to form based challenge and response but is
authorized on a per unit call basis. This example assumes that the web service
/services/StatelessService has been configured and is available to a client, but that authorization has not been enabled. This example also assumes that the security
realm has been enabled with a user principal with the needed roles for authorization.


1. Begin by specifying the web deployment descriptor (web.xml) for the web
application in which you will deploying your web service. This will restrict
the authorization to the web service.




<security-constraint>
<web-resource-collection>
<web-resource-name>private stateless web service</web-resource-name>
<url-pattern>/services/StatefulService</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>webserviceuser</role-name>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>

<login-config>
<auth-method>BASIC</auth-method>
<realm-name>noiSecurityRealm</realm-name>
</login-config>
<security-role>
<role-name>webserviceuser</role-name>
</security-role>
<security-role>
<role-name>webuser</role-name>
</security-role>
<security-role>
<role-name>admin</role-name>
</security-role>


2. Enable the client call.

The client unit call needs to support the user principle and passord attributes
to be passed in BASIC authorization for the security realm.



package com.noi.mailservice.web.clients;

import org.apache.axis.client.*;
import org.apache.axis.*;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.utils.Options;

import org.apache.axis.transport.http.*;
import org.apache.axis.deployment.wsdd.*;
import org.apache.axis.attachments.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.*;
import org.apache.axis.encoding.ser.*;
import javax.activation.*;

import java.net.*;
import java.io.*;

import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;

import javax.xml.rpc.ParameterMode;

import com.noi.utility.data.*;

import com.noi.mailservice.web.bl.*;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;

public class StatefulServiceClient
{
private static final boolean stateful = true;

public static void main(String [] args)
{
try {

String username = args[0];
String password = args[1];

Options options = new Options(args);

String endpointURL = options.getURL();
String configURL = "http://meis:8080/axisservices/wsdd/statefulclient-deploy.wsdd";
String textToSend;

args = options.getRemainingArgs();
if ((args == null) || (args.length < 1)) {
textToSend = "";
} else {
textToSend = args[0];
}

Service service = new Service();

//configure the stateful client engine
AxisEngine engine = service.getEngine().getClientEngine();

//get the configuration document
URL configresource = new URL(configURL);
XMLDocumentReader reader = new XMLDocumentReader();
reader.parse(configresource);
Document doc = reader.getDocument();

Element element = doc.getDocumentElement();

//use the document to cofigure the client engine
WSDDDocument wsddDoc = new WSDDDocument(element);
EngineConfiguration config = (EngineConfiguration)engine.getConfig();
if ( config instanceof WSDDEngineConfiguration) {
WSDDDeployment deployment = ((WSDDEngineConfiguration)config).getDeployment();
wsddDoc.deploy(deployment);
}
engine.refreshGlobalOptions();
engine.saveConfiguration();

//send the image
DataHandler dh = new DataHandler(new FileDataSource("D:\\clay\\images\\self\\tantor23-1.jpg"));

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

//add username and password properties
call.setProperty(Call.USERNAME_PROPERTY, username);
call.setProperty(Call.PASSWORD_PROPERTY, password);

call.setTargetEndpointAddress( new java.net.URL(endpointURL) );

call.setOperationName( new QName("StatefulService", "sendImage") );
QName qnDataHandler = new QName("StatefulService", "DataHandler");
call.registerTypeMapping(
DataHandler.class,
qnDataHandler,
new org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory(DataHandler.class, qnDataHandler),
new org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory(DataHandler.class, qnDataHandler)
);

call.addParameter( "dh", qnDataHandler, ParameterMode.IN);

call.setReturnType( qnDataHandler );
DataHandler ret = (DataHandler)call.invoke( new Object[] { dh } );


} catch (Exception e) {
System.err.println(e.toString());
e.printStackTrace();
}

}
}

Monday, January 03, 2005

[cookbook] stateful web sevices

Stateful services provide the web services developer with a way to
manage "seesion", here is a helpful cook book on how to create a statefull
axis based web service.

1. Create your service



/*
* StatefulService.java
*
* Created on April 1, 2003, 3:25 PM
*/

package com.noi.mailservice.web.services;

import com.noi.mailservice.web.bl.*;
import javax.activation.*;
import java.awt.*;
import javax.imageio.*;
import javax.imageio.stream.*;
import java.io.*;
import java.awt.image.*;
import java.util.*;
import javax.swing.*;
import org.apache.axis.attachments.*;


public class StatefulService
{
private String value;

public void setValue(String value)
{
this.value = value;
}

public String getValue(String empty)
{
return this.value;

}

public String[] getValues(String empty)
{
return new String[] {"hippy", "zippy", "flippy", "mippy", "tippy"};
}

public NameValue getNameValue(NameValue nv)
{
nv.setName("name1");
nv.setValue("VALUE1");
return nv;
}

public DataHandler sendImage( DataHandler dh){
try{
System.err.println("In sendImage");
System.err.println("handler content class:"+dh.getContent().getClass().getName());
dh.writeTo(new FileOutputStream(new File("/home/clay/tmp/myimage.jpg")));
}
catch(Exception e)
{
System.err.println("problem with send image:"+e.getMessage());
e.printStackTrace();
}
return dh;
}
}




2. Create your deployment file for stateful service. First you need a
deployment file for your service that allows for a stateful session handler.
I am using the Session handler that comes with axis. I place this file in
the application context such as [context]/wsdd/statefulservice-deploy.wsdd,
so it is expected to be there when the deployment servlet init is invoked.


 <?xml version="1.0" encoding="UTF-8"?>
<deployment
xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"
xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xmlns:ns1="StatefulService">

<service name="StatefulService" provider="java:RPC">
<namespace>http://meis/mailservice/</namespace>
<parameter name="scope" value="session"/>
<requestFlow>
<handler type="java:org.apache.axis.handlers.SimpleSessionHandler"/>
</requestFlow>
<responseFlow>
<handler type="java:org.apache.axis.handlers.SimpleSessionHandler"/>
</responseFlow>
<parameter name="className" value="com.noi.mailservice.web.services.StatefulService"/>
<parameter name="allowedMethods" value="*"/>
<operation name="getNameValue" returnQName="returnqname" returnType="ns1:NameValue" >
<parameter name="nv" type="ns1:NameValue"/>
</operation>
<operation name="sendImage" returnQName="returnqname" returnType="ns1:DataHandler" >
<parameter name="dh" type="ns1:DataHandler"/>
</operation>
<typeMapping deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
languageSpecificType="java:com.noi.mailservice.web.bl.NameValue"
qname="ns1:NameValue"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
<typeMapping deserializer="org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory"
languageSpecificType="java:javax.activation.DataHandler"
qname="ns1:DataHandler"
serializer="org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</service>
</deployment>




3. Deploy the stateful service.

I use a servlet as part of the web application that will deploy the service.
When its init method is called it configures the server service engine with
the above wsdd. This will atomatically deploy the service when the web application
file is deployed. package com.avexus.impresaservices.web.servlet;



/*
* ServicesDeploymentServlet.java
*
* Created on April 1, 2003, 5:39 PM
*/

package com.noi.mailservice.web.servlet;

import java.io.*;
import java.net.*;

import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.axis.transport.http.*;
import org.apache.axis.*;
import org.apache.axis.deployment.wsdd.*;

import java.net.*;

import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;

import java.io.*;

import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.*;

import com.noi.utility.data.*;


/**
*
* @author clay
* @version
*/
public class ServicesDeploymentServlet extends HttpServlet {

/** Initializes the servlet.
*/
public void init(ServletConfig sconfig) throws ServletException {
super.init(sconfig);
AxisServlet axisServlet = new AxisServlet();
ServletConfig sC = getServletConfig();
ServletContext context = this.getServletContext();
try {
axisServlet.init(sC);
} catch (ServletException e) {
e.printStackTrace();
}
try {
AxisEngine engine = axisServlet.getEngine();

String[] services = {"myservice", "statefulservice", "noimailservice"};
for(int i=0; i<services.length; i++)
{
URL deployURL = context.getResource("/wsdd/"+services[i]+"-deploy.wsdd");

//when parsing namespace MUST be aware
//Document doc = this.parse(deployURL);
XMLDocumentReader reader = new XMLDocumentReader();
reader.parse(deployURL);
Document doc = reader.getDocument();

Element element = doc.getDocumentElement();
WSDDDocument wsddDoc = new WSDDDocument(element);
EngineConfiguration config = (EngineConfiguration)engine.getConfig();

if ( config instanceof WSDDEngineConfiguration) {
WSDDDeployment deployment = ((WSDDEngineConfiguration)config).getDeployment();
wsddDoc.deploy(deployment);
}
engine.refreshGlobalOptions();
engine.saveConfiguration();
debug("Deployed web service:"+services[i]);

}
}
catch (IOException e) {
e.printStackTrace();
}
}

/** Destroys the servlet.
*/
public void destroy() {
//this should undeploy
}

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.close();
}

/** Handles the HTTP method.
* @param request servlet request
* @param response servlet response
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}

/** Handles the HTTP POST method.
* @param request servlet request
* @param response servlet response
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}

/** Returns a short description of the servlet.
*/
public String getServletInfo() {
return "The Service Deployment Servlet";
}

private void debug(String dval)
{
ServletContext context = getServletContext();
ServletConfig config = getServletConfig();
boolean debugflag = new Boolean(config.getInitParameter("servletdebug")).booleanValue();
if(debugflag)
{
context.log(dval);
}
}
}

4. Create the client configuration file

I place this file in the application context such as [context]/wsdd/statefuleclient-deploy.wsdd,
so it is expected to be there when the client is invoked.
<?xml version="1.0" encoding="UTF-8"?>
<deployment
xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"
xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">

<transport name="http" pivot="java:org.apache.axis.transport.http.HTTPSender"/>
<transport name="local" pivot="java:org.apache.axis.transport.local.LocalSender"/>
<transport name="java" pivot="java:org.apache.axis.transport.java.JavaSender"/>
<globalConfiguration>
<requestFlow>
<handler type="java:org.apache.axis.handlers.SimpleSessionHandler"/>
</requestFlow>
<responseFlow>
<handler type="java:org.apache.axis.handlers.SimpleSessionHandler"/>
</responseFlow>
</globalConfiguration>
</deployment>




5. Use your client application to access the service.

package com.noi.mailservice.web.clients;


import org.apache.axis.client.*;
import org.apache.axis.*;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.utils.Options;

import org.apache.axis.transport.http.*;
import org.apache.axis.deployment.wsdd.*;
import org.apache.axis.attachments.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.*;
import org.apache.axis.encoding.ser.*;
import javax.activation.*;

import java.net.*;
import java.io.*;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.ParameterMode;
import com.noi.utility.data.*;
import com.noi.mailservice.web.bl.*;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;

public class StatefulServiceClient
{
private static final boolean stateful = true;

public static void main(String [] args)
{
try {

Options options = new Options(args);

String endpointURL = options.getURL();
String configURL = "http://meis:8080/mailservice/wsdd/statefulclient-deploy.wsdd";
String textToSend;

args = options.getRemainingArgs();
if ((args == null) || (args.length < 1)) {
textToSend = "";
} else {
textToSend = args[0];
}

Service service = new Service();

//configure the stateful client engine
AxisEngine engine = service.getEngine().getClientEngine();

//get the configuration document
URL configresource = new URL(configURL);
XMLDocumentReader reader = new XMLDocumentReader();
reader.parse(configresource);
Document doc = reader.getDocument();

Element element = doc.getDocumentElement();

//use the document to cofigure the client engine
WSDDDocument wsddDoc = new WSDDDocument(element);
EngineConfiguration config = (EngineConfiguration)engine.getConfig();
if ( config instanceof WSDDEngineConfiguration) {
WSDDDeployment deployment = ((WSDDEngineConfiguration)config).getDeployment();
wsddDoc.deploy(deployment);
}
engine.refreshGlobalOptions();
engine.saveConfiguration();

//set the value
/*Call call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(endpointURL) );

//public boolean login(String protocol, String username, String password, String hostname)
call.setOperationName( new QName("StatefulService", "setValue") );
call.addParameter( "testval", XMLType.XSD_STRING, ParameterMode.IN);

//call.setReturnType( org.apache.axis.encoding.XMLType.XSD_STRING);

//String ret = (String) call.invoke( new Object[] { textToSend } );
call.setReturnType( org.apache.axis.encoding.XMLType.XSD_ANY);
call.invoke( new Object[] { textToSend } );

System.out.println(textToSend+" has successfully been set.");

//get the value
call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(endpointURL) );

call.setOperationName( new QName("StatefulService", "getValue") );
call.addParameter( "empty", XMLType.XSD_STRING, ParameterMode.IN);
call.setReturnType( org.apache.axis.encoding.XMLType.XSD_STRING);
String ret = (String)call.invoke( new Object[] { "empty" } );

System.out.println(ret+" has successfully been retrieved.");

//get values
call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(endpointURL) );

call.setOperationName( new QName("StatefulService", "getValues") );
call.addParameter( "empty", XMLType.XSD_STRING, ParameterMode.IN);
call.setReturnType( org.apache.axis.encoding.XMLType.SOAP_ARRAY);
Object[] retlist = (Object[])call.invoke( new Object[] { "empty" } );

for(int i = 0; i<retlist.length; i++)
{
String val = (String)retlist[i];
System.out.println("item #"+i+" value:"+val);
}

//get name value object;
call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(endpointURL) );
call.setOperationName( new QName("StatefulService", "getNameValue") );
NameValue nv = new NameValue();
QName qn = new QName("StatefulService", "NameValue");
call.registerTypeMapping(
NameValue.class,
qn,
new org.apache.axis.encoding.ser.BeanSerializerFactory(NameValue.class, qn),
new org.apache.axis.encoding.ser.BeanDeserializerFactory(NameValue.class, qn)
);

call.addParameter("source", qn,
ParameterMode.IN);

call.setReturnType(qn);
nv = (NameValue)call.invoke( new Object[] { (Object)nv } );

System.out.println("name:"+nv.getName()+" value:"+nv.getValue());*/

DataHandler dh = new DataHandler(new FileDataSource("D:\\clay\\images\\self\\tantor23-1.jpg"));

Call call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(endpointURL) );

call.setOperationName( new QName("StatefulService", "sendImage") );
QName qnDataHandler = new QName("StatefulService", "DataHandler");
call.registerTypeMapping(
DataHandler.class,
qnDataHandler,
new org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory(DataHandler.class, qnDataHandler),
new org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory(DataHandler.class, qnDataHandler)
);

call.addParameter( "dh", qnDataHandler, ParameterMode.IN);

call.setReturnType( qnDataHandler );
DataHandler ret = (DataHandler)call.invoke( new Object[] { dh } );


} catch (Exception e) {
System.err.println(e.toString());
e.printStackTrace();
}

}

}

the definitive rebel frameworks article

Ok, so here it is. The definitive article on creating web applications
using rebel frameworks such as Spring, STRUTS, and Hibernate. This is the
place to start and it gives the basic approach to create the whole shibang
wrapped up in a WAR file. Say goobye to J2EE, rebel frameworks are coming!

Wiring Your Web Application with Open Source Java