Popular Posts

Monday, October 6, 2008

SOAP over JMS with Axis2

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.ActiveMQInitialContextFactory</parameter>
<parameter name="java.naming.provider.url">tcp://localhost:61616 </parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName">TopicConnectionFactory </parameter>
</parameter>

<parameter name="myQueueConnectionFactory">
<parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory </parameter>
<parameter name="java.naming.provider.url">tcp://localhost:61616 </parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName">QueueConnectionFactory </parameter>
</parameter>

<parameter name="default">
<parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory </parameter>
<parameter name="java.naming.provider.url">tcp://localhost:61616 </parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName">QueueConnectionFactory </parameter>
</parameter>
</transportReceiver>

Also, uncomment the transport Sender which is in the Transport-outs section of axis2.xml.

<transportSender name="jms" class="org.apache.axis2.transport.jms.JMSSender"/>

Step3
The following ActiveMQ libraries must be copied to the Axis2 lib directory (AXIS2_HOME/lib).
  • activeio-core-3.1-SNAPSHOT.jar (ActiveMQ_Install_dir\lib\optional)
  • activemq-core-5.0.0.jar (ActiveMQ_Install_dir\lib\)
  • geronimo-j2ee-management_1.0_spec-1.0.jar (ActiveMQ_Install_dir\lib\)
  • geronimo-jms_1.1_spec-1.0.jar (ActiveMQ_Install_dir\lib\)
Step 4
Start Axis2server and go to http://localhost:8080
Then select the default version service.
The WSDL of the Version service will be displayed. You will notice the following port.

<wsdl:port name="VersionJmsSoap11Endpoint" binding="ns:VersionSoap11Binding">
<soap:address location="jms:/Version?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616"/>
</wsdl:port>

This implies that the Version service is now exposed over JMS transport as well. Lets write a client and send SOAP requests through JMS.

Step 5

Generate Client stubs with the following command.
AXIS2_HOME/bin/WSDL2Java -uri http://localhost:8070/axis2/services/Version?wsdl -o out -uw

The client stubs will be generated in a directory called "out".

Now, write a client importing the generated stub classes as follows(You can easily create a project in Eclipse using the generated Build.xml)

import java.rmi.RemoteException;
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import sample.axisversion.ExceptionException0;
import sample.axisversion.VersionStub;


public class JMSClient {

public static void main(String[] args) throws AxisFault{
ConfigurationContext cc = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,"D:\\axis2\\axis2-client\\conf\\axis2.xml");
String url = "jms:/Version?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616";
VersionStub stub = new VersionStub(cc,url);

try {
System.out.println(stub.getVersion());
} catch (RemoteException e) {
e.printStackTrace();
} catch (ExceptionException0 e) {
e.printStackTrace();
}
}

}

We need to enable JMS in client side too. Therefore, create a client repository (Just create a directory and copy the axis2.xml in there). Make sure to enable JMS transportReceiver and TransportSender in client's axis2.xml.

Step 6

Run the client. You will get the response back with axis2 version.
Now we need to look at the messages transmitted through JMS channel. Open a command prompt and type 'jconsole' and hit enter.
Connect to ActiveMQ agent.
Click on MBeans and select org.apache.activemq mbean.
Select localhost --> Queue

Run the client few times and note the queue size.

21 comments:

adno said...

I got This failer

Exception in thread "main" org.apache.axis2.deployment.DeploymentException

can you help me please

Rino said...

I believe the problem you are having is that you are not finding the axis2 repository. In the call createConfigurationContextFromFileSystem, specify the location of your axis2 repository. Something like:
ConfigurationContext cc = ConfigurationContextFactory
.createConfigurationContextFromFileSystem("C:\\axis2-1.4.1\\repository",
"C:\\axis2-1.4.1\\axis2-client\\axis2.xml");

Machera said...

Actually, we don't need to pass the ConfigurationContext as a parameter to construct a stub. The alternative approach is to modify the axis2_default.xml in package org.apache.axis2.deployment and to uncomment the JMS transportSender setting.
Then just like the normal http request, no more configurationContext required.
cheers

balaji said...

i am getting the following error when i try to invoke the JMS WebService

[java] java.security.AccessControlException: access denied (java.lang.Runti
mePermission modifyThread)
[java] at java.security.AccessControlContext.checkPermission(AccessCont
rolContext.java:264)
[java] at java.security.AccessController.checkPermission(AccessControll
er.java:427)

can you please help me?

crystal said...

Fantastic!God bless you!Meanwhile,you can visit my China Wholesale,we have the highest quality but the lowest price fashion products wholesale from China.Here are the most popular China Wholesale productsfor all of you.You can visit http://chinaclothes.net.Also the polo clothing is a great choice for you.
http://www.pumafr.com/blog
http://poloshirtsonline.blogspot.com
http://thediary.org/mensclothing
http://blog.livedoor.jp/dokoma
http://www.itimes.com/my_blog.php

crystal said...

Do not mean bad.Thank you so much!I just want to show some fashion things to all of you.I like puma speed, puma femmes and other puma shoes. These puma sport items are at store recently and available for anyone.

crystal said...

Perfect!!You are a outstanding person!Have you ever wore chaussures puma,Here are the most popular puma CAT,Puma shoes store gives some preview of puma speed cat,and casual but no sweat puma basket.

crystal said...

God bless you!I really agree with your opinions.Also,there are some new fashion things here,gillette razor blades.gillette mach3 razor bladesfor men.As for ladies,gillette venus razor blades must the best gift for you in summer,gillette fusion blades are all the best choice for you.

crystal said...

Awesome!!!Best wishes for you !!cheap polo shirts is the father of the summer should be prepared to most commonly used item, it has both style and shape of Ralph Lauren Polo, and vest with a random function polo ralph lauren, so that in the short-sleeved apply to both on many occasions, the pink and black color men's polo shirts brought into effect, lightweight cotton, linen texture to demonstrate masculine temperament and sense of fashion exhaustively.

crystal said...

Thank you so much!!polo shirt men'ssweate,Burberry Polo Shirts lacoste sweater, ralph lauren Columbia Jackets,ski clothing. Free Shipping, PayPal Payment. Enjoy your shopping experience on mensclothingus.com.You can find the father who desire fashionable, intellectual mens clothing simultaneously.

srggy said...

The larger that the head size is for your babolat pure drive, the more power you will be provided with. Additionally, a larger wilson k six size means a larger sweet spot which is why beginners as well as intermediate players often prefer to work with a head microgel with a larger head size. Additionally, thicker frames are also capable of generating more power as well. Smaller head sizes on prince-o3-tour on the other hand are capable of providing less power, but significantly more control cheap tennis racquets.new polos men poloswomen polosdiscount polossummer polospolo shirts whosalepolo fashionembroodered polostennis racketsclothing poloclothingedhardyshirtedhardyclothingsummer ed hardy clothingcheap shirtsed hardy brand.

srggy said...

Although many people criticize ed hardy clothing for having nothing but tattoo patterns, being filled with waste and useless things, it is widely acknowledged that ed hardy clothes draws the most attention of both common young people as well as many Hollywood welcomed stars for its punk ed hardy t-shirts rock styles. As a matter of fact, in such a world where all ed hardy shirts are much like each other, ed hardy mens creates yet another totally new global sensation in fashion crowd for ed hardy womens fancy design. An increasing number of people are charmed by the magic of amazing tattoo and impressive color of ed hardy sunglasses.

srggy said...

In this version of the ralph lauren polo, the styling and fabric is advertised as being made out of "playdry" material. Burberry Polo Shirts is another performance fabric which is intended to add luxury Cheap polo shirts, coolness, and moisture wicking qualities. Performance fabrics wholesale polo shirtswere originally created primarily for athletes and other sports enthusiasts who work up a good sweat ralph lauren polo shirts. The moisture wicking fabric in cheap ralph lauren polos draws the moisture away from the body which then evaporates quickly discount ralph lauren polos. ralphlaurenpoloshirts keep the body cooler and drier even when the athlete is under physical duress polo clothing.

srggy said...

polo ralph lauren RED! Series of design criteria - stylish, simple, self-cultivation. For the first time in 2009 in New York Fashion Week debut, RED! Series has a new Polo Shirts On Sale series from the traditional burberry polos LOGO, LOGO traditional crocodile logo at the Ralph Lauren Polo Shirts letter above, and the new series of letters with the cheappolos logo in line to be between a red symbol of Burberry Polo Shirts.

lla said...

In preparation for the purchase of a tennis racquetbefore, we must consider your financial ability to bear; On this basis, a further comparison, as far as possible, choose your head tennis racquets. Now a lot of babolat pure drive and more mixed materials, the proportion of mixed-use to control the stiffness of the babolat aeropro drive and the shock-absorbing capacity, the more rigid babolat tennis racket, the swing more powerful force; but the relative resilience of the shock-absorbing capacity and wilson k factor performance of talks on the easier it is for the wrist and elbow injury.
Wholesale Handbags
Cheap Handbags
Womens Handbags
Cheap Purses
Designer Handbags

lla said...

Burberry polo shirt the steady, solid, so many young girls also love it. Speaking of people of a ralph lauren polo, think it a sign of nobility elegant waving in the horse club.spyder jacket in the cold in your winter activities can be easily.columbia jacket it is expensive, but here you do not need to consider the price of it. the north face jacket one of my favorite money, I do not know how many in this world of its fans.
ed hardy clothing
ed hardy clothes
ed hardy shirts
ed hardy t-shirts
ed hardy sunglasses
ed hardy mens
ed hardy womens

lla said...

http://2009tennis.blogspot.com/
http://www.free-blog-site.com/tennis
http://o3.indiatimes.com/racquet/
http://cid-8c8a918b06ff68fd.spaces.live.com/?lc=2052
http://2009tennis.cocolog-nifty.com/
http://2009tennis.blog.drecom.jp/
http://2009tennis.blog.shinobi.jp/
http://www.actiblog.com/slary/
http://pshirts.blog126.fc2.com/
http://www.free-blog-site.com/shirts
http://nikepuma.blog.shinobi.jp/
http://hardy55.blog126.fc2.com/
http://cid-f80137f6d1a8020b.spaces.live.com/?lc=2052
http://www2.atword.jp/sdgdyhd/
http://kurumaro.com/hardy/
http://hardyclothes.jugem.jp/
http://www.actiblog.com/sfawagfra/
http://thediary.org/cheaphandbags/
http://ameblo.jp/kaowy/
http://sale.edublogs.org/
http://www2.atword.jp/jak/
http://09handbags.blog126.fc2.com/
http://sun15.cocolog-nifty.com/
http://ameblo.jp/ailsa15/
http://junior2tennis.blog.shinobi.jp/

swimingfidh said...

http://sweetygirlbirdylove.blog126.fc2.com/
http://wholesale-from-china-susan.blogspot.com/
http://caihongbao.blog126.fc2.com/
http://alisasweetybabyb.blog.shinobi.jp/
http://kurumaro.com/alisasweetybaby/
http://yahoewholesales.blogspot.com/
http://susanyahoe.blog126.fc2.com/
susanyahoe.wordpress.com
suanyaheo.blogsome.com
http://sexywomenjeans.blogspot.com/
http://eliotkusith.blog126.fc2.com/
http://eliotsmart.edublogs.org/
http://blog.qlep.com/blog.php/eyecatchingjeans
http://uniquejeanscloset.blogspot.com/
http://andrewmirrerredjean.blog126.fc2.com/
http://d.hatena.ne.jp/uniquejeans/
http://blog.goo.ne.jp/uniquejeanslove/
http://www4.atword.jp/unequejeansfans/
http://johnwired123.blog126.fc2.com/
http://d.hatena.ne.jp/johnwired123/
http://ameblo.jp/johnwired123/
http://www.seriousblogging.com/johnwired123/
http://mybrandnewclothes123.blogspot.com/

swimingfidh said...

There are ed hardy shirts
,pretty ed hardy shirt for men,

ed hardy womens in the ed hardy online store

designed by ed hardy ,
many cheap ed hardy shirt ,glasses,caps,trouers ed hardy shirts on sale ,

You can go to edhardyshirts.com to have a look ,you may find one of ed hardy clothing fit for you
Top qualitymen's jacket,
These cheap jacket are on sale now,you can find
north face jackets inmage on our web
Ralph Lauren Polo Shirtsbuberry polo shirts

Do you wannaghd hair straighteners for you own , we have many
cheap ghd hair straightenersin style and great,you can choose one from these
hair straighteners
Authentic chaussure puma
chaussure sport
And chaussure nike shoes

swimingfidh said...

Come here to have a look of our Wholesale Jeans
Many fashionMens Jeans ,eye-catching
Womens Jeans ,and special out standing
Blue Jeans ,you can spend less money on our
Discount Jeans but gain really fine jeans, absolutely a great bargain.
www.crazypurchase.com
China Wholesale
wholesale from china
buy products wholesale
China Wholesalers
http://www.weddingdressseason.com

Vishal Agrahari said...

Hi...
I am new to the web services and looking for a SOAP over JMS implementation. I am using Jboss web server and wanted to implement java web services using SOAP over JMS with Axis2 engine.

It would be really great if you can provide the same kind of example for JBoss MQs.

Thanks in advance,
Vishal