Friday, February 29, 2008

Common Regular Expression For JAVA


Form Validation REGEX Expression For JAVA


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ONLY ALPHA
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

REGEX = "^[a-zA-Z]+(([\'\,\.\-][a-zA-Z])?[a-zA-Z]*)*$";

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
APLPH WITH SPACE
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

REGEX = "^[a-zA-Z]+((\s|\-)[a-zA-Z]+)?$";

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ONLY NUMBER without white space
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

REGEX = "[0-9]*";

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ONLY TEXT without white space
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

REGEX = "[a-zA-Z]*";

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E-MAIL Validator
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

REGEX = "^[^_.]([a-zA-Z0-9_]*[.]?[a-zA-Z0-9_]+[^_]){2}@{1}[a-z0-9]+[.]{1}(([a-z]{2,3})|([a-z]{2,3}[.]{1}[a-z]{2,3}))$";

Friday, February 15, 2008

Stub Creation with Apache Axis (WSDL2Java)

1. Download Axis from http://www.apache.org/dyn/closer.cgi/ws/axis/1_4 select appropriate mirror an can download binary or source version from that.

2. Unzip the folder to C:\tools\axis-1_4 dir.
Here we installed both of src and binary version and you will get following structure.

3. Now the time to generate Stub for WebService.
for that Axis provide one class named WSDL2Java.

Let's use this file. For that follow the step.

Set Class path for Axis.
- Create a axis.bat file with following data
-------Axis.bat Start ------------
set AXIS_HOME=c:\tools\axis-1_4
set AXIS_LIB=%AXIS_HOME%\lib
set AXISCLASSPATH=%AXIS_LIB%\axis.jar;
%AXIS_LIB%\commons-discovery-0.2.jar;
%AXIS_LIB%\commons-logging-1.0.4.jar;
%AXIS_LIB%\jaxrpc.jar;
%AXIS_LIB%\saaj.jar;
%AXIS_LIB%\log4j-1.2.8.jar;
%AXIS_LIB%\wsdl4j-1.5.1.jar;
%AXIS_LIB%\endorsed\xml-apis-2.6.2.jar;
%AXIS_LIB%\endorsed\xercesImpl-2.6.2.jar;
%AXIS_LIB%\log4j-1.2.8.jar;
%AXIS_LIB%\jaxrpc.jar;
---------Axis.bat End------------

Make sure AXISCLASSPATH should be in single line.

4. Now run the following command from command prompt.
c:\>axis.bat

c:\> java -cp %AXISCLASSPATH% org.apache.axis.wsdl.WSDL2Java (WSDL-file-URL)

5. Now at C: the Service Stub created successfully.

And ready to use.


Contributors