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 "Mayne, Peter" <Pe...@ap.spherion.com> on 2003/08/28 07:46:10 UTC

Axis code generation HOW-TO

I'm just starting out with Axis, so I haven't learned the tricks of the
trade yet.

I have a class p.C, which contains at least one method that returns an
object of class p.R and throws an exception p.E.

I use axis-java2wsdl (from Ant within Eclipse) to generate a .WSDL file from
p.C, and then axis-wsdl2java to generate the .java files in the package
p.axis.

However, my p/R.java and p/E.java files are overwritten by wsdl2java, which
isn't nice.

If I now add my functionality to the generated p/R.java and p/E.java, and
then later on modify my p.C class and regenerate the WSDL and Axis .java
files, my p/R.java and p/E.java files will get overwritten again by the
plain wsdl2java generated classes.

On the other hand, if I add another method to p.C that returns an object of
class p.R2, I need to implement p.R2 to write my method, but I want
wsdl2java to generate p/R2.java so I can manually merge my p.R2 with the
Axis-generated p.R2, without overwriting my existing p/R.java and p/E.java.

I can do what the axis-wsdl2java doc suggests, and generate the .java files
somewhere else and use a <copy> task to copy the ones I want, but I still
have to manually change

Whatever happens, it seems there's no way around a fair amount of manual
work every time something changes.

Am I missing something here? What's the best way to do code management,
particularly in an Eclipse environment?

Thanks.

PJDM
-- 
Peter Mayne
Technology Consultant
Spherion Technology Solutions
Level 1, 243 Northbourne Avenue, Lyneham, ACT, 2602
T: 61 2 62689727  F: 61 2 62689777

The information contained in this email and any attachments to it:

(a) may be confidential and if you are not the intended recipient, any interference with, 
use, disclosure or copying of this material is unauthorised and prohibited; and

(b) may contain personal information of the recipient and/or the sender as defined 
under the Privacy Act 1988 (Cth). Consent is hereby given by the recipient(s) to 
collect, hold and use such information and any personal information contained in a 
response to this email, for any reasonable purpose in the ordinary course of 
Spherion's 
business, including forwarding this email internally or disclosing it to a third party. All 
personal information collected by Spherion will be handled in accordance with 
Spherion's Privacy Policy. If you have received this email in error, please notify the 
sender and delete it.

(c) you agree not to employ or arrange employment for any candidate(s) supplied in 
this email and any attachments without first entering into a contractual agreement with 
Spherion. You further agree not to divulge any information contained in this document 
to any person(s) or entities without the express permission of Spherion.



Re: Axis code generation HOW-TO

Posted by Stuart Barlow <sb...@peopledoc.com>.
The main reason I went for the whole loop (Java2WSDL and WSDL2Java)
was to see how AXIS was interpretting my types. Maps became HashMaps,
contained Collections became arrays, and Exceptions moved to being
derived from AxisFault.

So that lead me to remove all Collections from my interface and
move to simple arrays. Make it easy for interoperability.

And I thought that AXIS would be happiest working with its
interpretation of the interface.

Ajay Gondhiya wrote:

> Stuart,
> 
> I am new to Axis and trying to understand the steps you mentioned in which 
> you used Java2WSDL and then again WSDL2Java. In a simple prototype, I am 
> just using Java2WSDL to generate WSDL from EJB interfaces and then 
> deploying the EAR file on JBoss. That seems to be working fine. However, I 
> have used only simple types for parameter (Strings mostly).
> In my scenario, I have not seen any need for running WSDL2Java again so 
> what's that I am missing?
> Thanks a lot !
> 
> Ajay
> 
> 
> 
> 
> Stuart Barlow <sb...@peopledoc.com> 
> 08/28/2003 01:58 PM
> Please respond to
> axis-user@ws.apache.org
> 
> 
> To
> axis-user@ws.apache.org
> cc
> 
> Subject
> Re: Axis code generation HOW-TO
> 
> 
> 
> 
> 
> 
> You are right that its a bit fiddly. But with ANT you can automate
> the whole process.
> 
> My process...
> 1. Take original API classes and build.
> 2. Run Java2WSDL to generate WSDL.
> 3. Run WSDL2Java to generate new API .java files and bindings.
> 4. Chuck away original API classes and copy new .java files into main
>     source tree.
> 5. Compile all the classes.
> 6. Take the generated deploy.wsdd and copy into server-config.wsdd
>     so that when tomcat deploys war file the service is included.
> 7. Change the service 'className' to my real implementation that is
>     part of my original code.
> 
> Most important part - Get ANT to do the whole thing!
> If eclipse can't cope then chuck it and use jEdit. :-)
> Keep implementation completely separate from API.
> 
> Mayne, Peter wrote:
> 
>>I'm just starting out with Axis, so I haven't learned the tricks of the
>>trade yet.
>>
>>I have a class p.C, which contains at least one method that returns an
>>object of class p.R and throws an exception p.E.
>>
>>I use axis-java2wsdl (from Ant within Eclipse) to generate a .WSDL file 
> 
> from
> 
>>p.C, and then axis-wsdl2java to generate the .java files in the package
>>p.axis.
>>
>>However, my p/R.java and p/E.java files are overwritten by wsdl2java, 
> 
> which
> 
>>isn't nice.
>>
>>If I now add my functionality to the generated p/R.java and p/E.java, 
> 
> and
> 
>>then later on modify my p.C class and regenerate the WSDL and Axis .java
>>files, my p/R.java and p/E.java files will get overwritten again by the
>>plain wsdl2java generated classes.
>>
>>On the other hand, if I add another method to p.C that returns an object 
> 
> of
> 
>>class p.R2, I need to implement p.R2 to write my method, but I want
>>wsdl2java to generate p/R2.java so I can manually merge my p.R2 with the
>>Axis-generated p.R2, without overwriting my existing p/R.java and 
> 
> p/E.java.
> 
>>I can do what the axis-wsdl2java doc suggests, and generate the .java 
> 
> files
> 
>>somewhere else and use a <copy> task to copy the ones I want, but I 
> 
> still
> 
>>have to manually change
>>
>>Whatever happens, it seems there's no way around a fair amount of manual
>>work every time something changes.
>>
>>Am I missing something here? What's the best way to do code management,
>>particularly in an Eclipse environment?
>>
>>Thanks.
>>
>>PJDM
> 
> 
> 
> 


Re: Axis code generation HOW-TO

Posted by Ajay Gondhiya <Aj...@accelrys.com>.
Stuart,

I am new to Axis and trying to understand the steps you mentioned in which 
you used Java2WSDL and then again WSDL2Java. In a simple prototype, I am 
just using Java2WSDL to generate WSDL from EJB interfaces and then 
deploying the EAR file on JBoss. That seems to be working fine. However, I 
have used only simple types for parameter (Strings mostly).
In my scenario, I have not seen any need for running WSDL2Java again so 
what's that I am missing?
Thanks a lot !

Ajay




Stuart Barlow <sb...@peopledoc.com> 
08/28/2003 01:58 PM
Please respond to
axis-user@ws.apache.org


To
axis-user@ws.apache.org
cc

Subject
Re: Axis code generation HOW-TO






You are right that its a bit fiddly. But with ANT you can automate
the whole process.

My process...
1. Take original API classes and build.
2. Run Java2WSDL to generate WSDL.
3. Run WSDL2Java to generate new API .java files and bindings.
4. Chuck away original API classes and copy new .java files into main
    source tree.
5. Compile all the classes.
6. Take the generated deploy.wsdd and copy into server-config.wsdd
    so that when tomcat deploys war file the service is included.
7. Change the service 'className' to my real implementation that is
    part of my original code.

Most important part - Get ANT to do the whole thing!
If eclipse can't cope then chuck it and use jEdit. :-)
Keep implementation completely separate from API.

Mayne, Peter wrote:
> I'm just starting out with Axis, so I haven't learned the tricks of the
> trade yet.
> 
> I have a class p.C, which contains at least one method that returns an
> object of class p.R and throws an exception p.E.
> 
> I use axis-java2wsdl (from Ant within Eclipse) to generate a .WSDL file 
from
> p.C, and then axis-wsdl2java to generate the .java files in the package
> p.axis.
> 
> However, my p/R.java and p/E.java files are overwritten by wsdl2java, 
which
> isn't nice.
> 
> If I now add my functionality to the generated p/R.java and p/E.java, 
and
> then later on modify my p.C class and regenerate the WSDL and Axis .java
> files, my p/R.java and p/E.java files will get overwritten again by the
> plain wsdl2java generated classes.
> 
> On the other hand, if I add another method to p.C that returns an object 
of
> class p.R2, I need to implement p.R2 to write my method, but I want
> wsdl2java to generate p/R2.java so I can manually merge my p.R2 with the
> Axis-generated p.R2, without overwriting my existing p/R.java and 
p/E.java.
> 
> I can do what the axis-wsdl2java doc suggests, and generate the .java 
files
> somewhere else and use a <copy> task to copy the ones I want, but I 
still
> have to manually change
> 
> Whatever happens, it seems there's no way around a fair amount of manual
> work every time something changes.
> 
> Am I missing something here? What's the best way to do code management,
> particularly in an Eclipse environment?
> 
> Thanks.
> 
> PJDM



Re: Axis code generation HOW-TO

Posted by Stuart Barlow <sb...@peopledoc.com>.
You are right that its a bit fiddly. But with ANT you can automate
the whole process.

My process...
1. Take original API classes and build.
2. Run Java2WSDL to generate WSDL.
3. Run WSDL2Java to generate new API .java files and bindings.
4. Chuck away original API classes and copy new .java files into main
    source tree.
5. Compile all the classes.
6. Take the generated deploy.wsdd and copy into server-config.wsdd
    so that when tomcat deploys war file the service is included.
7. Change the service 'className' to my real implementation that is
    part of my original code.

Most important part - Get ANT to do the whole thing!
If eclipse can't cope then chuck it and use jEdit. :-)
Keep implementation completely separate from API.

Mayne, Peter wrote:
> I'm just starting out with Axis, so I haven't learned the tricks of the
> trade yet.
> 
> I have a class p.C, which contains at least one method that returns an
> object of class p.R and throws an exception p.E.
> 
> I use axis-java2wsdl (from Ant within Eclipse) to generate a .WSDL file from
> p.C, and then axis-wsdl2java to generate the .java files in the package
> p.axis.
> 
> However, my p/R.java and p/E.java files are overwritten by wsdl2java, which
> isn't nice.
> 
> If I now add my functionality to the generated p/R.java and p/E.java, and
> then later on modify my p.C class and regenerate the WSDL and Axis .java
> files, my p/R.java and p/E.java files will get overwritten again by the
> plain wsdl2java generated classes.
> 
> On the other hand, if I add another method to p.C that returns an object of
> class p.R2, I need to implement p.R2 to write my method, but I want
> wsdl2java to generate p/R2.java so I can manually merge my p.R2 with the
> Axis-generated p.R2, without overwriting my existing p/R.java and p/E.java.
> 
> I can do what the axis-wsdl2java doc suggests, and generate the .java files
> somewhere else and use a <copy> task to copy the ones I want, but I still
> have to manually change
> 
> Whatever happens, it seems there's no way around a fair amount of manual
> work every time something changes.
> 
> Am I missing something here? What's the best way to do code management,
> particularly in an Eclipse environment?
> 
> Thanks.
> 
> PJDM