Thursday, February 1, 2007

Writing a simple Axis Web Service

If I am going to be doing any real BPEL development. I really have to be able to make my own web services. I basically stripped out the BPEL and JSP components of the loan approval example.

I created a simple java class that will be exposed as a web service:

Web Service:

package com.smith.ws;
import java.util.Date;

public class SimpleWebService {

public String simpleCall(String someString)
throws SimpleWebServiceProcessFault
{
String response = null;
try
{
System.out.println("Calling "+this.getClass());
//do some business logic
Date now = new Date();
response = "*"+someString+"*"+now;
}
catch (Exception e)
{
throw new SimpleWebServiceProcessFault("simpleCall", e.toString(),"99");
}
return response;
}
}


You then have to update the service.wsdd file to expose it as a web service:

Service.wsdd

Something like:

< name="SimpleWebService" provider="java:RPC">

< name="className" value="com.smith.ws.SimpleWebService">
< name="allowedMethods" value="*">

<>


The ant build creates a simplewebservices.wsr and copies it to the /bpr directory

Calling the web service:

Service service = new Service();
Call call = (Call)service.createCall();
String urlString = "http://localhost:8080/active-bpel/services/SimpleWebService";
call.setTargetEndpointAddress(new java.net.URL(urlString));
call.setOperationName("simpleCall");
call.addParameter("someString", org.apache.axis.Constants.XSD_STRING,ParameterMode.IN);
call.setReturnType(org.apache.axis.Constants.XSD_STRING);

String result = null;
try
{
result = (String)call.invoke(new Object[] {"My Call"});
}
catch (AxisFault af) {
if (SimpleWebServiceProcessFault.hasMagicFaultErrorCode(af))
result = "99";
else
result = af.toString();
}
catch (Exception e) {
result = "unexpected exception seen: " + e.toString();
}

System.out.println("Client result = " + result);


Basically taking the input argument and returning it dressed up with some asterisks and the current time.

Sample run:
Client result = *My Call*Thu Feb 01 20:13:33 MST 2007


You can download the sample simple web service bundle here:
1simplews.zip

9 comments:

Anonymous said...

Hi,
is there an easy way to deploy the simple webservice that u r providing as a zip file.

Can it be extracted and the entire folder copied to webapps of the server to make the sevice available?

-xyz

Anonymous said...

I just discovered the website who reviews about
many
home business ideas

If you want to know more here it is
home business ideas

Anonymous said...

The writer of techinitiatives.blogspot.com has written a superior article. I got your point and there is nothing to argue about. It is like the following universal truth that you can not disagree with: Every bloke has at some stage while taking a pee flushed half way through and then raced against the flush. I will be back.

Anonymous said...

[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]experience with levitra [/url]

[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]side efect o levitra [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]santa claus levitra jokes [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]levitra quick prescription [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]levitra online shop in uk [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]levitra free levitra find charles edinburgh [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]levitra and hemmhroids [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]buy levitra online au [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]babys lungs and levitra [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]levitra usage information [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]dog heartfailure levitra [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]generic levitra buy levitra online levitra [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]drug generic levitra [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]levitra song lyrics [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]levitra order online [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]levitra and nitroglycern [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]experience with levitra [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]how to get levitra hmo [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]levitra for sale online [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]levitra boy [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]levitra discount drug [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]g postmessage levitra subject remember [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]u 3312 levitra cialis [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]readily available alternatives to levitra [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]anger and levitra [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]confidential overnight shipping levitra overnight [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]pfizer levitra pharmacy [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]levitra cocaine [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]watermelon or levitra [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]sildenafil efectsfrom side levitra [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]side-efects levitra [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]levitra and nitroglycern [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]what is levitra triangle chicago [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]air order travel levitra videos [/url]
[url=http://www.atv.com/forum/showthread.php?p=26410#post26410]levitra side efects warnings [/url]

Anonymous said...

Associatedcontentnetwork.com Article directory free for publish your press release and articles !

Anonymous said...

Bu sohbet sitesi tek kelimeyle Muhtes. Sohbet Etmek ve Arkadas, Olmak için Arad? Seçmenin Faydalar?

Anonymous said...

[b][url=http://www.uggsclearancemall.co.uk/]www.uggsclearancemall.co.uk[/url][/b] A Louis Vuitton Amelia Wallet is likewise a great choice of xmas present ideas unique. It can be delicately produced from perforated Monogram Louis Vuitton calf leather-based with calf leather-based lining and golden brass items. Eighteen credit card slots are relatively valuable for your good friend.

[b][url=http://www.uggsbootsoutletmall.co.uk/]uggs boots outlet[/url][/b] For those of you who skydive (or those who watched it on Television), you realize that every transfer is important. That why you practice a lot. Knitting has some crucial moves, also. Renowned firms are domestic names. They are really the A-list of corporate global; master-marketers effective at driving residence all of the advantages of size, electric power and presence concurrently because they press the emotional flesh with manufacturers that happen to be pretty cool and have massive personalized charm. Timberland, Mercedes, Vodafone, Nike, Adidas, Mars, Tag Heuer, Everlast, Michelon and Bvlgari attraction for the individualist/collectivist dichotomy in all of us.

[b][url=http://www.bestlouisvuittonbags.co.uk/]louis vuitton handbags[/url][/b] In the course of these fairs, folks come all decked out in medieval-inspired costumes-kings or queens in complete regalia, knights in chain mail armors and medieval swords, and beautiful medieval girls wearing humble costumes that were widespread through all those times. Aside within the clothes, people also recreate the food items and dishes that were served during that time, medieval game titles and pursuits, and even talk in previous English language like a tribute to this period. For anybody that is a person these types of hobbyist or have however to show up at your 1st truthful, you must be genuinely excited to go the following 1.

[b][url=http://www.uggsonsalewebsite.co.uk/]ugg boots sale[/url][/b] Strategy playdates. Talk to the preschool's director for any class record (or at least several names and quantities), and prepare several playdates so your soon-to-be preschooler may get to understand her new classmates. Some preschools sponsor picnics or potlucks for incoming college students along with their moms and dads; if yours won't, look at arranging your individual potluck or pizza bash on the college playground (with permission) or at a close by park..

[b][url=http://www.uggsclearancemall.co.uk/]uggs clearance[/url][/b] Promptly following all, Belt is a unique needed fashion accessory for guys aside from watches. Factors ought to commonly be initial thing you could ought to aim on, it doesnot subject which kind of products it's possible you'll be buying. Males's belts, leather-based is just with regard to the regular content.

Anonymous said...

Please, keep to the point.
I think, that you are mistaken. Let's discuss.
This information is true
I apologise, but it does not approach me. There are other variants?
I congratulate, the remarkable answer...

[url=http://shenenmaoyiww.devhub.com/][b]michael kors outlet online[/b][/url]
[url=http://www.shenenmaoyitt.350.com/page-1.htm][b]michael kors outlet online[/b][/url]
[url=http://www.homebasedbusinessprogram.com/profiles/blogs/motorcycle-tool-bags-keeping-the-tools-organized-and-accessible][b]michael kors outlet online[/b][/url]
[url=http://shenenmaoyizzz.blog.fc2blog.net/blog-entry-1.html][b]michael kors outlet online[/b][/url]
[url=http://shenenmaoyitt.bloghi.com/][b]michael kors outlet online[/b][/url]

Anonymous said...

http://hermeshandbags.citationguide.net hemres bags outlet cheap hermes handbags uk