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