This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Services and the fly likes Axis 1.3 - WSDL2JAVA issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Axis 1.3 - WSDL2JAVA issue" Watch "Axis 1.3 - WSDL2JAVA issue" New topic
Author

Axis 1.3 - WSDL2JAVA issue

Vasa Sk
Greenhorn

Joined: May 05, 2010
Posts: 4
Axis gurus,

I am learning axis as part of my job and came accros following issue.

I am generating WSDL files through Ant Axis using JAVA2WSDL tool and converting generated WSDL file to JAVA using WSDL2JAVA. I have created one of the web service which returns array of custom Java class. I am running into issues when generating code from WSDL to JAVA, it is writing additional code to the Custom Java class.

Really appreciate your answer on this are direct me where I can find the answer and what to look for (BTW I have google for solution but not able to find a solution or not able to stitch things together).

1. I am using following technologies:

- Java - 1.5
- Eclipse IDE Ganymede
- Axis 1.3
- Ant Contrib 0.6
- antlr - 2.7.5H3

2. I am using "RPC" as JAVA2WSDL/WSDL2JAVA style (no enclosing style)


Examples():

Service method: public DenomPortfolioVO[] getAllDenoms()
Custom Class:

public class DenomPortfolioVO extends VisualObject implements Serializable {

/** logger for the class */
private static final Logger log = Logger.getLogger(DenomPortfolioVO.class);

/**
* Serialization version id
*/
private static final long serialVersionUID = 1L;

private String code;
private String category;
private String descr;
private String grpPrtInd;
private String activeYN;
private String lotType;
private String notes;

/**
* DenomPortfolioVO
*/
public DenomPortfolioVO()
{
super();
log.trace("DenomPortfolioVO()");
}

/**
* Get the id from the record
*
* @return Long - id
*/
public Long getId() {
return super.getId();
}

/**
* Sets the id for the record
*
* @param Long - id
*/
public void setId(Long id) {
super.setId(id);
}

/**
* Get the Modified YN from the record
*
* @return String - ModifiedYN
*/
public String getModifiedYN() {
return super.getModifiedYN();
}

/**
* Sets the Modified YN for the record
*
* @param String - modYN
*/
public void setModifiedYN(String modYN) {
super.setModifiedYN(modYN);
}

/**
* get the code from the record
*
* @return String - code
*/
public String getCode(){
return this.code;
}

/**
* Sets the code for the record
*
* @param String - denomCode
*/
public void setCode(String denomCode) {
this.code = denomCode;
}

/**
* get the code from the record
*
* @return String - category
*/
public String getCategory(){
return this.category;
}

/**
* Sets the code for the record
*
* @param String - denomCategory
*/
public void setCategory(String denomCategory) {
this.category = denomCategory;
}

/**
* get the Description from the record
*
* @return String - descr
*/
public String getDescr(){
return this.descr;
}

/**
* Sets the Description for the record
*
* @param String - denomDescr
*/
public void setDescr(String denomDescr) {
this.descr = denomDescr;
}

/**
* get the GroupPort Indicator from the record
*
* @return String - grpPrtInd
*/
public String getGrpPrtInd(){
return this.grpPrtInd;
}

/**
* Sets the GroupPort Indicator for the record
*
* @param String - grpPrtInd
*/
public void setGrpPrtInd(String denomGrpPrtInd) {
this.grpPrtInd = denomGrpPrtInd;
}

/**
* get the Active YN Indicator from the record
*
* @return String - activeYN
*/
public String getActiveYN(){
return this.activeYN;
}

/**
* Sets the Active YN for the record
*
* @param String - activeYN
*/
public void setActiveYN(String denomActiveYN) {
this.activeYN = denomActiveYN;
}

/**
* get the Lot Type from the record
*
* @return String - lotType
*/
public String getLotType(){
return this.lotType;
}

/**
* Sets the Lot Type for the record
*
* @param String - lotType
*/
public void setLotType(String denomLotType) {
this.lotType = denomLotType;
}

/**
* get the Notes from the record
*
* @return String - notes
*/
public String getNotes(){
return this.notes;
}

/**
* Sets the Notes for the record
*
* @param String - notes
*/
public void setNotes(String denomNotes) {
this.notes = denomNotes;
}


Thanks in advance.
R Srini
Ranch Hand

Joined: Feb 19, 2010
Posts: 215
Hi. I have no Axis experience. But I am trying to understand this. So:

1. You have a regular POJO class DenomPortfolioVO with private fields and getters and setters.
2. You are generating WSDL files through Ant Axis using JAVA2WSDL tool, i.e. you have custom Java code, and you are generating a WSDL
3. We will assume that the WSDL is good to go, published and accessible.
4. You have a web service that returns an array of DenomPortfolioVO

My current understanding is this:

a) If you have a wsdl and you want to consume web services that the wsdl represents, then you use wsdl2java to get your starter classes and then customize the code.
b) And if you have java code that you want to expose as a web service, then you use java2wsdl

My reference for wsdl2java: http://ws.apache.org/axis/java/user-guide.html#WSDL2JavaBuildingStubsSkeletonsAndDataTypesFromWSDL
And java2wsdl: http://ws.apache.org/axis/java/user-guide.html#Java2WSDLBuildingWSDLFromJava

This is what I am trying to understand:
I am running into issues when generating code from WSDL to JAVA

Question: Why are you running wsdl2java? Don't you already have the Java code (from java2wsdl) that you used to generate the WSDL in the first place? What is the intention?
Vasa Sk
Greenhorn

Joined: May 05, 2010
Posts: 4

Thanks for your immediate response and the references, I will view them shortly.

My original question may not clear, but I do not have a WSDL. I am trying to create WSDL file first using ANT JAVA2WSDL and then trying to convert WSDL from using ANT WSDL2JAVA.

R Srini
Ranch Hand

Joined: Feb 19, 2010
Posts: 215
First: If you are using Axis 1.3 (not Axis2), then you can follow this tutorial, that would be best. Or for Axis2, you can try this tutorial. Now, out of curiousity, I did give your scenario a try, and this is what I found (remember that I am new to Axis ). Sorry for the rather long email. I realize you are using Ant, but I did not use Ant. Hope it will still help a little.

Assuming that you are using Axis2 1.3 (not the older Axis 1.3), I tried the following using Axis2 1.5.1. Files are in the same directory, default package.






This generates the following artifacts in outdir:
1. build.xml
2. src\org\apache\ws\axis2\xsd\DenomPortfolioVO.java
public class DenomPortfolioVO implements org.apache.axis2.databinding.ADBBean
3. src\bindingfiles\DenomServiceSkeletonInterface.java
4. src\bindingfiles\DenomServiceMessageReceiverInOut.java
... and some more like the client stub, etc. if you use the -g option

Ok. This is the point I wanted to get to.
Question: Re #2 above - DenomPortfolioVO.java - Is this the generated class you are referring to that has the same name as your custom class and is overwriting it? If yes, just put it in a separate package using the -p option and it won't overwrite your code. It contains the code to convert xml to your custom class (java object) and back. So you will probably need it at some point to get to the data inside the xml.

Some references that might be useful
This article explains a lot about the generated code, i.e. the purpose of the generated classes.
Reference for ant tasks using the code generator included with Axis2. Just use the same options as in the command above.
And here is another way to do the code generation using ant by directly calling org.apache.axis2.wsdl.WSDL2Java and passing it the same parameters.

Hope this helps somewhat.
Vasa Sk
Greenhorn

Joined: May 05, 2010
Posts: 4

Hi Srini,

Thanks the for the help, that sheds some light. However just to clarify, I am using 1.2 not 1.3 of Axis old version (I found following in manisfest file):

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.5.3
Created-By: 1.4.2_05-b04 (Sun Microsystems Inc.)

Name: org/apache/axis
Implementation-Title: Apache Axis
Implementation-Version: 1.2.1 2243 June 14 2005
Implementation-Vendor: Apache Web Services


Yes, you are right on the overwriting the class. I understand what you trying to say to avoid overwriting the file and how this generated code will be needed in future. Just to avoid this generated code file, is there a way that I can use BeanType, DataType I can use in Server-Configuration.wsdd?

I understand you are learning but I am trying to learn with you as well.

Thanks for all the information you have provided so far. That will help me customize my code further.



R Srini
Ranch Hand

Joined: Feb 19, 2010
Posts: 215
I haven't heard of BeanType. You have to have a lot of things in place before you get this to work.

Your wsdd file will end up looking something like this:
Here are a few links that talk about this:

1. http://www.javaranch.com/journal/200603/WSComplexTypes.html
2. http://www.developer.com/open/article.php/10930_3443951_1/Developing-Java-Web-Services-with-AXIS.htm
3. You will find lots of good information in the IBM developerWorks site. Search for "axis wsdd"
Vasa Sk
Greenhorn

Joined: May 05, 2010
Posts: 4
You are right. I have mistyped, it should ready as BeanMapping instead of BeanType. Thanks for all the information you provided.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

"Sk Technical", please check your private messages for an important administrative matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Axis 1.3 - WSDL2JAVA issue
 
Similar Threads
Using java.lang.Arraylist object in WSAD WebServices
Adding SelectList Value into DB
Record getting inserted instead of update
Compare these classes!
How to get aroun LazyInitialization exceptions using Spring HibernateDaoSupport?