Posts

Showing posts from October, 2008

Changing the default class loading mechanism of JBoss 4.2.* and WebLogic

Application servers use different class loading/delegation mechanisms. Therefore, we should understand them when deploying enterprise applications. In most cases, we need to override the default class loading behavior of application servers. Suppose your web application wants to load classes from its own class loader first without delegating to parent. Then the following simple configurations will help you to override default delegation pattern in BEA WebLogic (version 8.* or 10) and JBOSS 4.2.*. In WebLogic : Set <prefer-web-inf-classes> to true in WEB-INF/weblogic.xml of your war. Read WebLogic Server application classloading for more information. In JBoss : Set java2ParentDelegation to false in WEB-INF/jboss-web.xml as follows. <loader-repository> org.test:loader=archive-name <loader-repository-config> java2ParentDelegation=false </loader-repository-config> </loader-repository> For more information about JBoss class loading, have a look at JBoss cla

How to use Maven2 WSDL2Code plugin in Axis2

Image
Apache Axis2 ships with a lot of useful tools to make web service developer's life easier. Maven2 WSDL2Code plugin is one of them which can be used to generate server side skeletons or client stubs from a given WSDL using a maven pom.xml. Lets see how this plugin can be used. Pre-requistes : Apache Maven2 Step1 Create a maven project using maven archetype template (You may ignore this step and use an existing project if you are familiar with maven) mvn archetype:create -DgroupId=com.test -DartifactId=calculator This will create a maven project structure as follows. Step 2 Create a directory (i.e:- resources) at src\main and copy your WSDL file there. Now, remove the existing contents of the auto-generated pom.xml (calculator\pom.xml) and add the following configuration. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/m

RESTful PHP Web Services by Samisa Abeysinghe

Image
Samisa Abeysinghe , the director of engineering at WSO2 , attempts to explain the basic architectural concepts and step through examples of consuming and creating RESTful web services in PHP through his new book. This should be a vital reference for anyone interested in SOA. You could find more details of this book from PACKT web.

Reading a property of Axis2 services.xml from service Implementation class

There have been questions raised in Axis2 user list about reading some properties defined in services.xml from service implementation class. An easy way of doing that is as follows. 1. Suppose your services.xml is as follows and it has a parameter named, TestProperty. <service name="ParameterService"> <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">org.test.MyParameterService</parameter> <parameter name="TestProperty">This is a test property</parameter> </service> 2. We need to read the value of "Te

How to make an OSGI bundle using maven bundle plugin

Image
OSGI (Open systems Gateway Initiative) specification defines a complete and dynamic component model which can be remotely installed, started, updated, stopped and uninstalled without restarting JVM. I'm not going to discuss the specification details of OSGI. You can find a lot of information from www.osgi.org The objective of this post is to create a simple OSGI bundle using Apache Felix maven bundle plugin . Pre-requisites: Apache Maven2 Step 1 First we need to create a simple java class and which must be included in a proper directory structure therefore we can use Maven2 to build the source. Create the following directory structure in your file system. Create the following interface. package org.wso2; public interface GreetingService { public void sayGreeting(String s); } Create an Impl directory under wso2 and add the following class in there. package org.wso2.Impl; import org.wso2.GreetingService; public class GreetingServiceImpl implements GreetingService { public v

How to add a custom SOAP header to the request using AXIOM

Suppose you want to add the following SOAP header block to your web service request message. <myNS:header xmlns:myNS="http://ws.org"> This is a custom soap header </myNS:header > There are different approaches to add user defined headers to the request soap messages. Lets see how it could be done using AXIOM in simpler way. In this example we are going to invoke Axi2 default version service with adding a custom soap header in to the request. Pre-requisites Download and install Apache Axis2 Install Apache Tcpmon Step 1 Start Axis2 server by running AXIS2_HOME/bin/axis2server.bat{sh} Go to http://localhost:8080. You will see that the default version service is deployed there. Step 2 Now, we need to generate client stubs. Go to AXIS2_HOME/bin and run wsdl2java.bat{sh} with the following parameters. WSDL2Java -uri http://localhost:8080/axis2/services/Version?wsdl -o out -uw The client stubs will be generated in a directory called "out". Now, write a client

SOAP over JMS with Axis2

Image
Axis2 provides a JMS transport implementation which can be used to send SOAP messages over JMS. This post will help you to - Configure JMS transport in Axis2 Generate Axis2 client Invoke default version service by sending request SOAP message over JMS Monitoring messages via JConsole I assume Apache ActiveMQ is used as our JMS implementation. However, you are free to use any other stack. Pre-requisites 1. Install the latest version of Apache Axis2 binary distribution 2. Install Apache ActiveMQ 5.0.0 Step 1 First, we need to start ActiveMQ message broker. Go to ActiveMQ_Install_dir/bin and run activemq.bat Step 2 In order to configure the JMSListener in axis2.xml, uncomment the following section. <transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener"> <parameter name="myTopicConnectionFactory"> <parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFa

How to deploy JSR181 annotated class in Apache Axis2

Image
JAX-WS (Java API for XML Web Services) provides support for annotating Java classes with metadata to indicate that the Java class is a Web service. With the annotations, you can expose java classes as web services with minimum effort. Apache Axis2 ships with JAX-WS support since its 1.4 release. This post explains the simplest possible scenario of JAX-WS support, how you can deploy an annotated class in Axis2. Pre-requisites Apache Axis2-1.4 or later JDK1.5 or above Step 1 Write an annotated class as follows. package org.apache.axis2; import javax.jws.WebMethod; import javax.jws.WebService; @WebService public class Calculator { @WebMethod public double Add(double x, double y){ return x+y; } } Here, the @WebService annotation tells the server runtime to expose all public methods on the above class as a Web service. Also, with the @WebMethod annotation, you can specifically denotes the methods which are exposed in the web service. Step 2 Package the above class as a JAR (