+ Start a Discussion
MotokiMotoki 

WSDL2Java help

I'm a newbie in this Salesfore Java developement... i just want to write a very simple Java program that do some salesforce queries like inserting, upserting data... like the quickstartJava sample...
 
My current set up is:
Tomcat 4.1
Java SDK 1.5
Axis 1.4
 
When i tried to convert the enterprise.wsdl from my salesforce account to java classes, i got a list of exception errors... can someone help me understand what is going on?  Many thanks!
 
Code:
java org.apache.axis.wsdl.WSDL2Java enterprise.wsdl
log4j:WARN No appenders could be found for logger (org.apache.axis.i18n.ProjectR
esourceBundle).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" java.lang.NoClassDefFoundError: javax.wsdl.Definition

        at org.apache.axis.wsdl.toJava.JavaGeneratorFactory.class$(JavaGenerator
Factory.java:68)
        at org.apache.axis.wsdl.toJava.JavaGeneratorFactory.addDefinitionGenerat
ors(JavaGeneratorFactory.java:179)
        at org.apache.axis.wsdl.toJava.JavaGeneratorFactory.addGenerators(JavaGe
neratorFactory.java:133)
        at org.apache.axis.wsdl.toJava.JavaGeneratorFactory.<init>(JavaGenerator
Factory.java:111)
        at org.apache.axis.wsdl.toJava.Emitter.<init>(Emitter.java:159)
        at org.apache.axis.wsdl.WSDL2Java.createParser(WSDL2Java.java:209)
        at org.apache.axis.wsdl.gen.WSDL2.<init>(WSDL2.java:96)
        at org.apache.axis.wsdl.WSDL2Java.<init>(WSDL2Java.java:194)
        at org.apache.axis.wsdl.WSDL2Java.main(WSDL2Java.java:371)

 
SuperfellSuperfell
You're missing a jar from your classpath, double check your classpath against the axis docs.
MotokiMotoki

Thanks Simon,

That's strange... i have included the log4j-1.2.8.jar in the AXISCLASSPATH... but somehow it is not finding it...

MotokiMotoki

I have fixed the missing classes issue but now when i execute the command again i got another Exceptions:

Is this because of the enterprise.wsdl is not well formed?  Thanks!

Code:

java org.apache.axi
s.wsdl.WSDL2Java enterprise.wsdl
java.net.MalformedURLException: no protocol: enterprise.wsdl
        at java.net.URL.<init>(Unknown Source)
        at java.net.URL.<init>(Unknown Source)
        at java.net.URL.<init>(Unknown Source)
        at org.apache.xerces.impl.XMLEntityManager.startEntity(XMLEntityManager.
java:807)
        at org.apache.xerces.impl.XMLEntityManager.startDocumentEntity(XMLEntity
Manager.java:753)
        at org.apache.xerces.impl.XMLDocumentScannerImpl.setInputSource(XMLDocum
entScannerImpl.java:260)
        at org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.jav
a:499)
        at org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.jav
a:581)
        at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
        at org.apache.xerces.parsers.DOMParser.parse(DOMParser.java:253)
        at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.
java:201)
        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)

D:\Documents and Settings\Richie Chik\Desktop\SecheduleCheck>


 

SuperfellSuperfell
Sounds like you need to specify the WSDL file as a file:/// URI, not just a filename
MotokiMotoki

Hi Simon, i'm sorry to bother you again... i tried add file:/// to the command line but i still get exception...

Thank you.

Code:

java org.apache.axis.wsdl.WSDL2Java file:///enterprise.wsdl
java.io.FileNotFoundException: \enterprise.wsdl (The system 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 java.net.URL.openStream(Unknown Source)
        at org.apache.xerces.impl.XMLEntityManager.startEntity(XMLEntityManager.
java:807)
        at org.apache.xerces.impl.XMLEntityManager.startDocumentEntity(XMLEntity
Manager.java:753)
        at org.apache.xerces.impl.XMLDocumentScannerImpl.setInputSource(XMLDocum
entScannerImpl.java:260)
        at org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.jav
a:499)
        at org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.jav
a:581)
        at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
        at org.apache.xerces.parsers.DOMParser.parse(DOMParser.java:253)
        at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.
java:201)
        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)

D:\Documents and Settings\Richie Chik\Desktop\SecheduleCheck>


 

Michael SnowMichael Snow
You may still be missing jars.  In my classpath, I use:
.;./lib/AXIS.jar;./lib/axis-ant.jar;./lib/commons-discovery-0.2.jar;
./lib/commons-logging-1.0.4.jar;./lib/jaxrpc.jar;./lib/saaj.jar;
./lib/wsdl4j-1.5.1.jar;./lib/log4j-1.2.8.jar;./lib/mail.jar;./lib/activation.jar

I haven't needed to add file:///
CodeTalkerCodeTalker

I also haven't needed to specify "file:///"

I use an ant build file and eclipse to generate mine. (I do specify the full classpath C:\ ... ).

Looking at your code ...

Is your wsdl in this directory?

D:\Documents and Settings\Richie Chik\Desktop\SecheduleCheck>

It may not like spaces in "Documents and Settings".

I've had that problem before.

 

 

 

Michael SnowMichael Snow
Yes, the WSDL is in the directory that I executed Java from. 

Could you try:
java -classpath ./AXIS.jar;./axis-ant.jar;./commons-discovery-0.2.jar;./commons-logging-1.0.4.jar;./jaxrpc.jar;./saaj.jar;./wsdl4j-1.5.1.jar;./log4j-1.2.8.jar;./mail.jar;./activation.jar org.apache.axis.wsdl.WSDL2Java enterprise.wsdl

As long as everything is in the same directory (all jars and WSDL) this should just work for you. 
MotokiMotoki
I have solved that problem by using the Partner API and included all the jar files in my classpath at while ago but forgot to update this entry.
 
Thanks for your help anyway.