You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Richard Hu <Ri...@jda.com> on 2009/05/01 21:12:21 UTC
Best way to add a function to an existing Axis 2 service
Hi everyone,
This may be a silly question but what's the best way to add a function
to an existing Axis 2 service? I wrote an Axis 2 service from scratch
that has over a 100 functions by first creating the WSDL and then
running WSDL2Java and implementing the business logic in the Skeleton
class. Now I want to add a function. If I add it to the WSDL and
re-run WSDL2Java, then at best, I'll have to copy and paste code from
the old Skeleton class to the new one, which is unwieldy.
What's the best way of adding a function to an existing Axis 2 service
that was written from scratch using WSDL2Java?
Thanks,
Richard
Re: Best way to add a function to an existing Axis 2 service
Posted by Dennis Sosnoski <dm...@sosnoski.com>.
Hi Richard,
The best way to handle this is by keeping your implementation code
separate from the generated codes. For the server code, the easy way to
do this is by extending the generated XXXSkeleton class with your own
implementation class, which overrides all the methods of the skeleton.
Then replace the reference to the Skelton class with your implementation
class in the generated services.xml file. That way you can easily
regenerate the code from a modified WSDL when you add new operations,
and just override the added methods. The only downside is that if you
miss overriding a method you'll get a runtime exception rather than a
compile-time error, but that's generally pretty easy to deal with.
This is a common issue when web services are under development, so I
recommend this approach in all my trainings. In your case you can just
rename your existing edited Skeleton from the previous generation and
move it outside the generated code, then have it extend the newly
generated version of the Skeleton.
The sample code for my article
http://www.ibm.com/developerworks/webservices/library/ws-java3/ takes
this approach of separating the implementation code from the generated
code, using an Ant build.xml to automate the substitution. You might
want to download the samples and take a look. The 1.3 version of the
samples should be compatible with the Axis2 1.4/1.5 releases, except in
the case of the ADB unwrapped interface - that changed slightly between
1.3 and 1.4.
- Dennis
--
Dennis M. Sosnoski
SOA and Web Services in Java
Axis2 Training and Consulting
http://www.sosnoski.com - http://www.sosnoski.co.nz
Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117
Richard Hu wrote:
>
> Hi everyone,
>
> This may be a silly question but what’s the best way to add a function
> to an existing Axis 2 service? I wrote an Axis 2 service from scratch
> that has over a 100 functions by first creating the WSDL and then
> running WSDL2Java and implementing the business logic in the Skeleton
> class. Now I want to add a function. If I add it to the WSDL and
> re-run WSDL2Java, then at best, I’ll have to copy and paste code from
> the old Skeleton class to the new one, which is unwieldy.
>
> What’s the best way of adding a function to an existing Axis 2 service
> that was written from scratch using WSDL2Java?
>
> Thanks,
>
> Richard
>
Re: Best way to add a function to an existing Axis 2 service
Posted by Deepal jayasinghe <de...@gmail.com>.
I do not understand what do you mean by you first create the service and
then generate the WSDL and from that you generate the service skeleton.
If you already have the service why do you want to generate the skeleton
?, which is not need.
If you have created the service from WSDL2Java then the best way is to
edit the WSDL and then code gen. Or you could add the method to
Skeleton, but you have to make sure you somehow reflect that to WSDL.
Deepal
>
> Hi everyone,
>
> This may be a silly question but what’s the best way to add a function
> to an existing Axis 2 service? I wrote an Axis 2 service from scratch
> that has over a 100 functions by first creating the WSDL and then
> running WSDL2Java and implementing the business logic in the Skeleton
> class. Now I want to add a function. If I add it to the WSDL and
> re-run WSDL2Java, then at best, I’ll have to copy and paste code from
> the old Skeleton class to the new one, which is unwieldy.
>
> What’s the best way of adding a function to an existing Axis 2 service
> that was written from scratch using WSDL2Java?
>
> Thanks,
>
> Richard
>
--
Thank you!
http://blogs.deepal.org
http://deepal.org
RE: Best way to add a function to an existing Axis 2 service
Posted by "Jain, Prateek" <Pr...@premiereglobal.com>.
You can try using inheritance here. Put all business logic in child
class.
Regards,
Prateek Jain
Senior Software Engineer
Tel. +91-124-3936144 | Mob. +91-9958646136
iSmart Panache (I) Solutions Pvt. Ltd.
Plot No. 52, Sector 32, Institutional Area, Gurgaon 122001, Haryana
www.ismartpanache.com <http://www.ismartpanache.com/>
<http://www.ismartpanache.com/>
-----------------------------------------------------
Expectations ::: causes all troubles
-----------------------------------------------------
________________________________
From: Richard Hu [mailto:Richard.Hu@jda.com]
Sent: Saturday, May 02, 2009 12:42 AM
To: axis-user@ws.apache.org
Subject: Best way to add a function to an existing Axis 2 service
Hi everyone,
This may be a silly question but what's the best way to add a function
to an existing Axis 2 service? I wrote an Axis 2 service from scratch
that has over a 100 functions by first creating the WSDL and then
running WSDL2Java and implementing the business logic in the Skeleton
class. Now I want to add a function. If I add it to the WSDL and
re-run WSDL2Java, then at best, I'll have to copy and paste code from
the old Skeleton class to the new one, which is unwieldy.
What's the best way of adding a function to an existing Axis 2 service
that was written from scratch using WSDL2Java?
Thanks,
Richard