If you get out of memory exceptions while using maven you can tweak the amount of heap space available to the JVM with the following environment variable,
export MAVEN_OPTS=-Xmx512m
I didn't test any other but i presume you can set other Java options also with the same variable.
Showing posts with label development. Show all posts
Showing posts with label development. Show all posts
Tuesday, January 5, 2010
Monday, November 2, 2009
Creating a simple web service using Axis2
This post will briefly outline how I implemented a sample web service using Axis2 POJOs. First you need to setup a project directory for you. It should be structed like this:
Implement a simple java (POJO) with one setter and one getter. This will be the
server side of the web service.
ExampleService.java
Steps to build and deploy locally,
That's it.
In my next post I will show how to do the client side using gSOAP and C/C++.
Related reads:
- Axis2 POJO Tutorial
- services.xml description
Reference services.xml:
<service name="ExampleService" scope="application">
<description>My example service</description>
<messageReceivers>
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only" class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
</messageReceivers>
<parameter name="ServiceClass">
mywebservice.ExampleService
</parameter>
</service>
Reference ant file, store this as build.xml:
rootdir/build.xml
rootdir/src/META-INF
rootdir/src/META-INF/services.xml
rootdir/src/mywebservice
rootdir/src/mywebservice/ExampleService.java
Implement a simple java (POJO) with one setter and one getter. This will be the
server side of the web service.
ExampleService.java
package mywebservice;
public class ExampleService
{
float someValue = 42;
public float getSomeValue()
{
return someValue;
}
public void setSomeValue(float someValue)
{
this.someValue += someValue;
}
}
Steps to build and deploy locally,
- Build the web service using by running ant in the root directory.
- Copy the whole build/MyWebService directory into /var/lib/tomcat6/webapps/axis2/WEB-INF/services/MyWebService
- Check that http://localhost:8080/axis2/services/listServices lists your new web service.
- You can look at the WSDL document by clicking on your services.
That's it.
In my next post I will show how to do the client side using gSOAP and C/C++.
Related reads:
- Axis2 POJO Tutorial
- services.xml description
Reference services.xml:
<service name="ExampleService" scope="application">
<description>My example service</description>
<messageReceivers>
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only" class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
</messageReceivers>
<parameter name="ServiceClass">
mywebservice.ExampleService
</parameter>
</service>
Reference ant file, store this as build.xml:
<project name="MyWebService" basedir="." default="generate.service">
<property name="service.name" value="MyWebService">
<property name="dest.dir" value="build">
<property name="dest.dir.classes" value="${dest.dir}/${service.name}">
<property name="dest.dir.lib" value="${dest.dir}/lib">
<property name="axis2.home" value="../../axis2-1.5">
<property name="repository.path" value="${axis2.home}/repository">
<path id="build.class.path">
<fileset dir="${axis2.home}/lib">
<include name="*.jar">
</fileset>
</path>
<target name="prepare">
<mkdir dir="${dest.dir}">
<mkdir dir="${dest.dir}/lib">
<mkdir dir="${dest.dir.classes}">
<mkdir dir="${dest.dir.classes}/META-INF">
</target>
<target name="clean">
<delete dir="${dest.dir}">
<delete dir="src" includes="sample/pojo/stub/**">
</target>
<target name="generate.service" depends="clean,prepare">
<copy file="src/META-INF/services.xml" tofile="${dest.dir.classes}/META-INF/services.xml" overwrite="true">
<javac listfiles="yes" srcdir="src" destdir="${dest.dir.classes}" includes="mywebservice/**">
<classpath refid="build.class.path">
</javac>
<jar basedir="${dest.dir.classes}" destfile="${dest.dir}/${service.name}.aar">
<copy file="${dest.dir}/${service.name}.aar" tofile="${repository.path}/services/${service.name}.aar" overwrite="true">
</target>
</project>
Tuesday, October 20, 2009
Getting started with web services.
So, I finally decided to upgrade my buzzword bingo and try to out what all the cool business software consultants are up to. The task of the day is to create a web service using Java and whatever tools exist. I spent hours on Google and Wikipedia and didn't really get anywhere, I was completely lost in all of the services, servlets, webapps, soap, tomcats and tomboys that I encountered. Enough with the chit chat, this is what I ended up doing to get create my very own simple web service.
References.
1. Tomcat 6 on Ubuntu. https://help.ubuntu.com/8.10/serverguide/C/tomcat.html
- Start out with your normal Ubuntu installation
- Install Tomcat. You'll need the following packages: tomcat6, tomcat6-docs, tomcat6-examples, tomcat6-admin
- Edit /etc/default/tomcat6 and add "TOMCAT6_SECURITY=no". See Reference #2
- Make sure Tomcat is working by visiting http://localhost:8080/
- Download the standard binary distribution and the web archive distribution (WAR) from http://ws.apache.org/axis2/download.cgi
- Extract and copy axis2.war to /var/lib/tomcat6/webapps
- Make sure Axis2 is working properly by visiting http://localhost:8080/axis2/
References.
1. Tomcat 6 on Ubuntu. https://help.ubuntu.com/8.10/serverguide/C/tomcat.html
Subscribe to:
Posts (Atom)