aspose file tools*
The moose likes Web Services and the fly likes can't generate java from wsdl file please help! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "can Watch "can New topic
Author

can't generate java from wsdl file please help!

steve labar
Ranch Hand

Joined: Sep 10, 2008
Posts: 55
I'm so frustrated! I'm trying to simple convert the wsdl file to java code. However, this is a surprisingly big pain in the but. I'm a programmer so I can handle some technical stuff, but everything seems to be going wrong for me. Please help!

I have tried to install the axis/wsdl plugin for eclipse:

dragged the folders to eclipse plugin folder restarted eclipse........nothing shows up in the wizard

tried command line :

C:\Program Files\Java\jdk1.6.0_11\bin\axis2\axis2\bin>wsdl2java
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK/JRE

C:\Program Files\Java\jdk1.6.0_11\bin\axis2\axis2\bin>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.6.0_11\bin

C:\Program Files\Java\jdk1.6.0_11\bin\axis2\axis2\bin>wsdl2java -o Enterprise.w
dl
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK/JRE

I have java_home setup i think correctly but keep getting those errors?



tried netbean plugin with no luck. I tried with jaxb but i get "error while creating schema"



Please i'm out of options. How can i get this wsdl2java complete. I'm stuck at this process and would like to move forward.
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

I don't think the JAVA_HOME has been set in your environment variable. Try this in Windows command prompt.

If you don't see anything, that means the JAVA_HOME hasn't been set.

or else just modify the wsdl2java.bat and set the JAVA_HOME there.


SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
steve labar wrote:C:\Program Files\Java\jdk1.6.0_11\bin\axis2\axis2\bin>wsdl2java

Any particular reason that you are using Axis2 when you can be using JAX-WS which is included in Java SE 6?

steve labar wrote:I tried with jaxb but i get "error while creating schema"

Well the WSDL could be at fault. Check if the operation bindings use the "rpc/encoded" messaging mode. If they do, neither Axis2, nor JAX-WS (technically support is optional which means that it usually isn't implemented) will support consumption of WSDLs with "rpc/encoded" bindings. In that case you'll have to try Axis 1.x instead and pray that there are no interoperability problems between it and the web service provider - so there are no guarantees.

How can you tell?
See reading soap-envelop messages and Which style of WSDL should I use?
Other cases:
Can't generate java classes from WSDL file
Help! Wsdl2Java Can't parse a Coldfusion WSDL?

Also I'd stick with the command line tools for now so that you can gain more control over (and knowledge of) your development environment.
Examples:
Confusion in writing web service client + jax-ws
Passing Files in Web Services
steve labar
Ranch Hand

Joined: Sep 10, 2008
Posts: 55
I hope that more info may help generate something to help me. Here is what i have done thus far.

Ok. where to start. I have tomcat 4.1 installed at c:\tomcat4.1.



I have axis in C:\Tomcat4.1\webapps\axis. I have added this to my classpath



set CLASSPATH="C:\Tomcat4.1\webapps\axis\WEB-INF\lib\*"



lib has following jars:



axis

axis-ant

commons-logging-1.0.4

commons-discovery-0.2

jaxrpc

log4j-1.2.8

saaj

wsdl4j-1.5.1



I have read mail & activation must also be there however they were not in axis-bin_1.4 i downloaded. I'm thinking about taking those two from an axis2 i downloaded and moving them into lib but seems kinda strange to be mixig jars from different versions.



So I start tomcat and go to http://localhost:8080/axis/happyaxis.jsp and everything is ok except for an optional element:



Warning: could not find class org.apache.xml.security.Init from file xmlsec.jar
XML Security is not supported.
See http://xml.apache.org/security/





I'm assuming this is not my problem.



Now i try to go to the command line and enter:



C:\Documents and Settings\steve>java org.apache.axis.wsdl.WSDL2Java -a "C:\Tomca
t4.1\webapps\axis\enterprise.wsdl"
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/axis/wsdl/
WSDL2Java
Caused by: java.lang.ClassNotFoundException: org.apache.axis.wsdl.WSDL2Java
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: org.apache.axis.wsdl.WSDL2Java. Program will exi
t.



Then from reading around i have seen it is the setting up the classpath that is the most common issue so i try to explicitly enter in the class path:



java –classpath c:\Tomcat4.1\webapps\axis\WEB-INF\lib\axis.jar;C:\Tomcat4.1\webapps\axis\WEB-INF\lib\axis-ant.jar;C:\Tomcat4.1\webapps\axis\WEB-INF\lib\commons-discovery-0.2.jar;C:\Tomcat4.1\webapps\axis\WEB-INF\lib\commons-logging-1.0.4.jar;C:\Tomcat4.1\webapps\axis\WEB-INF\lib\jaxrpc.jar;C:\Tomcat4.1\webapps\axis\WEB-INF\lib\log4j-1.2.8.jar;C:\Tomcat4.1\webapps\axis\WEB-INF\lib\saaj.jar;C:\Tomcat4.1\webapps\axis\WEB-INF\lib\wsdl4j-1.5.1.jar;C:\Tomcat4.1\webapps\axis\WEB-INF\lib\wsdl4j-1.5.1.jar; org.apache.axis.wsdl.WSDL2Java -a C:\Tomcat4.1\webapps\axis\enterprise.wsdl


C:\Documents and Settings\steve>java -classpath c:\Tomcat4.1\webapps\axis\WEB-IN
F\lib\axis.jar;C:\Tomcat4.1\webapps\axis\WEB-INF\lib\axis-ant.jar;C:\Tomcat4.1\w
ebapps\axis\WEB-INF\lib\commons-discovery-0.2.jar;C:\Tomcat4.1\webapps\axis\WEB-
INF\lib\commons-logging-1.0.4.jar;C:\Tomcat4.1\webapps\axis\WEB-INF\lib\jaxrpc.j
ar;C:\Tomcat4.1\webapps\axis\WEB-INF\lib\log4j-1.2.8.jar;C:\Tomcat4.1\webapps\ax
is\WEB-INF\lib\saaj.jar;C:\Tomcat4.1\webapps\axis\WEB-INF\lib\wsdl4j-1.5.1.jar;C
:\Tomcat4.1\webapps\axis\WEB-INF\lib\wsdl4j-1.5.1.jar; org.apache.axis.wsdl.WSD
L2Java -a C:\Tomcat4.1\webapps\axis\enterprise.wsdl
Exception in thread "main" java.lang.NoClassDefFoundError: ûclasspath
Caused by: java.lang.ClassNotFoundException: ûclasspath
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: GÇôclasspath. Program will exit.







I'm confused when you enter in java org.apache.axis.wsdl.WSDL2Java where exactly is "org.apache.axis.wsdl.WSDL2Java" it was not in the axis1.4 bin from what i could see the onlything close was wsdl4j? I'm not seeing that in java as well. I thought wsdl2java was part of the axis package? I go into axis2-1.4.1 and there does exist wdsl2java ? Do i have the wrong axis? I was told not to use axis2 instead axis1.4.



Please i'm so frustrated and have tried everything i can possibly think of.

I need help!

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42951
    
  72
steve labar wrote:I'm confused when you enter in java org.apache.axis.wsdl.WSDL2Java where exactly is "org.apache.axis.wsdl.WSDL2Java" it was not in the axis1.4 bin from what i could see

I admit to not having read the entire thread so far, but the WSDL2Java class is in fact in the axis.jar that comes Axis 1.4 (it's 1.599.570 bytes big if you want to compare file sizes). Maybe you can take another look at it.

After looking closely at the last error, it's complaining about something else: "NoClassDefFoundError: ûclasspath". That sounds as if you entered a funny character instead of the "-" that goes before "classpath". Retry that with a proper minus sign and see what happens.
steve labar
Ranch Hand

Joined: Sep 10, 2008
Posts: 55
that did seem to change the error message to:

C:\Documents and Settings\steve>java -classpath c:\Tomcat4.1\webapps\axis\WEB-IN
F\lib\axis.jar;C:\Tomcat4.1\webapps\axis\WEB-INF\lib\axis-ant.jar;C:\Tomcat4.1\w
ebapps\axis\WEB-INF\lib\commons-discovery-0.2.jar;C:\Tomcat4.1\webapps\axis\WEB-
INF\lib\commons-logging-1.0.4.jar;C:\Tomcat4.1\webapps\axis\WEB-INF\lib\jaxrpc.j
ar;C:\Tomcat4.1\webapps\axis\WEB-INF\lib\log4j-1.2.8.jar;C:\Tomcat4.1\webapps\ax
is\WEB-INF\lib\saaj.jar;C:\Tomcat4.1\webapps\axis\WEB-INF\lib\wsdl4j-1.5.1.jar;C
:\Tomcat4.1\webapps\axis\WEB-INF\lib\wsdl4j-1.5.1.jar; org.apache.axis.wsdl.WSD
L2Java -a C:\Tomcat4.1\webapps\axis\enterprise.wsdl
- Unable to find required classes (javax.activation.DataHandler and javax.mail.i
nternet.MimeMultipart). Attachment support is disabled.
java.io.FileNotFoundException: C:\Tomcat4.1\webapps\axis\enterprise.wsdl (The sy
stem cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown So
urce)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrent
Entity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineD
ocVersion(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(U
nknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(U
nknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown So
urce)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown So
urce)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unk
nown Source)
at org.apache.axis.utils.XMLUtils.newDocument(XMLUtils.java:369)
at org.apache.axis.utils.XMLUtils.newDocument(XMLUtils.java:420)
at org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.jav
a:482)
at org.apache.axis.wsdl.gen.Parser$WSDLRunnable.run(Parser.java:361)
at java.lang.Thread.run(Unknown Source)


Your help is so very appreciated! Any ideas what this could be caused by?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42951
    
  72
Does the file mentioned in the error message exist, and is it readable by the user account that is running this command? Same question for all the directories involved (C:\Tomcat4.1, C:\Tomcat4.1\webapps and C:\Tomcat4.1\webapps\axis\).
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
steve labar wrote:I have read mail & activation must also be there however they were not in axis-bin_1.4 i downloaded. I'm thinking about taking those two from an axis2 i downloaded and moving them into lib but seems kinda strange to be mixig jars from different versions.


This doesn't address your primary problem, Ulf's latest questions are the most pertinent there - however you can get rid of the annoying "Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled." warning by using the activiation.jar from the JavaBeans Activation Framework (JAF) and the mail.jar from the JavaMail API.

Use the http://localhost:8080/axis/happyaxis.jsp page to determine whether you installed them correctly.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can't generate java from wsdl file please help!