Popular Posts

Wednesday, February 6, 2008

Exposing a spring bean as a web service

One of the major requirements expected from a web service framework is to expose the existing business components as web services. Spring framework has been using for Enterprise Application development for many years as it provides a more simpler approach than traditional J2EE application development.
WSO2 Web services application server provides an easy-to-use and efficient mechanism for exposing your Spring beans as java web service in a jiffy.

Pre-requisites:
WSO2 web services application server - WSAS2.2 (Download)

Step 1
As the first step, we should implement the Spring class (pojo) which needs to be exposed as the web service. I will write a very simple pojo which has one In-Out method as follows.

package org.ws.test;

public class Inoutbean {

public String echo(String s){
return s;
}

}
Compile and save the class.

Step 2

Now, we need to create the associated spring configuration file.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>
<bean id="InoutSpringBean" class="org.ws.test.Inoutbean">
</bean>
</beans>

Save the file as spring.xml

Step 3

Bundle the spring class in a jar so that it can be deployed on WSAS. Say the jar file is SpringBeans.jar

Steps 4
Start WSO2 Web services application server (WSAS) and access its management console using https://localhost:9443
Next, select 'Services' from the left navigation menu. You will be directed to the
'Service & Service Group Management' page.
Click on 'Upload Spring service' link.



Step 5
Next, select the SpringBeans.jar and the spring.xml and click on upload. You will be directed to the following screen.



You can select the spring bean from this screen and click on 'Generate' to complete the deployment.

Step 6
Now, the service deployment task is over and you can verify the service invocation with Tryit utility. Or else, just send a REST request as follows and check whether the expected output is returned in your browser
http://localhost:9762/services/InoutSpringBean/echo?s=hi

You may have noticed the ease-of-use when exposing a spring bean through WSO2 WSAS. The same procedure can be applied for any complex spring beans.
Before completing our scenario, you may have a look at the generated service archive by WSAS. It will reside at WSAS_HOME/repository/services. Open the 'SpringBeans.aar' and check the /META-INF/services.xml. You will see the following element there.
<parameter locked="true" name="ServiceObjectSupplier">org.wso2.wsas.admin.service.spring.GenericApplicationContextSupplier</parameter>
This is the most important entity of spring service generation and it instructs WSAS to load the Spring beans from the Spring configuration file.





12 comments:

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.
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...

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...

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...

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.
http://gilletterazor.blog.drecom.jp
http://www.getablog.net/ColumbiaJackets
http://crystal888.edublogs.org
http://blog.qlep.com/blog.php/gillette
http://chinaclothes.net

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...

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.

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.

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...

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.

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

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...

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/