Find your content:

Search form

You are here

How to Convert wsdl to java classes using apache axis

 
Share

Help me out to generate java classes from enterprise wsdl.

I followed this link: http://www.gerd-riesselmann.net/scala/creating-java-classes-wsdl-file-using-apache-axis-2

I installed apache axis and placed wsdl file in the bin\ directory of AXIS. downloaded few jars and placed in lib/ and SET the environment variables like JAVA_HOME, PATH and CLASSPATH

CLASSPATH:C:\Program Files\Java\jdk1.7.0_09\lib;C:\Program Files\Java\jdk1.7.0_09\jre\bin;D:\axis2-1.6.2-bin;D:\axis2-1.6.2-bin\axis2-1.6.2\lib\wsdl4j-1.6.2;D:\axis2-1.6.2-bin\axis2-1.6.2\lib\mail-1.4;D:\axis2-1.6.2-bin\axis2-1.6.2\lib\activation-1.1;D:\axis2-1.6.2-bin\axis2-1.6.2\lib\log4j-1.2.15;D:\axis2-1.6.2-bin\axis2-1.6.2\lib\axis2-ant-plugin-1.6.2;D:\axis2-1.6.2-bin\axis2-1.6.2\lib\saaj;D:\axis2-1.6.2-bin\axis2-1.6.2\lib\commons-discovery;D:\axis2-1.6.2-bin\axis2-1.6.2\lib\jaxrpc

AXISLIB:%AXIS_HOME%\lib

AXISCLASSPATH:%AXIS_LIB%\axis.jar;%AXIS_LIB%\commons-discovery.jar;%AXIS_LIB%\commons-logging-1.1.1.jar;%AXIS_LIB%\jaxrpc.jar;%AXIS_LIB%\saaj.jar;%AXIS_LIB%\log4j-1.2.15.jar;%AXIS_LIB%\xml-apis.jar;%AXIS_LIB%\xercesImpl.jar

When I run in command prompt:

D:\axis2-1.6.2-bin\axis2-1.6.2\bin> wsdl2java.bat -uri D:\axis2-1.6.2-bin\axis2-1.6.2\bin\enterprise.wsdl

I got below error,I didnt find any new folder with java classes in src/ folder.

Using AXIS2_HOME: D:\axis2-1.6.2-bin\axis2-1.6.2 Using JAVA_HOME: C:\Program Files\Java\jdk1.7.0_09 Retrieving document at 'D:\axis2-1.6.2-bin\axis2-1.6.2\bin\enterprise.wsdl'. Exception in thread "main" org.apache.axis2.wsdl.codegen.CodeGenerationException : Error parsing WSDL at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.(CodeGenerat ionEngine.java:178) at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:35) at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:24) Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=OTHER_ERROR: Unabl e to resolve imported document at 'D:\axis2-1.6.2-bin\axis2-1.6.2\bin\enterprise .wsdl'.: java.io.FileNotFoundException: This file was not found: file:/D:/axis2- 1.6.2-bin/axis2-1.6.2/bin/enterprise.wsdl at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source) at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source) at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.readInTheWSDLFile( CodeGenerationEngine.java:320) at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.(CodeGenerat ionEngine.java:133) ... 2 more Caused by: java.io.FileNotFoundException: This file was not found: file:/D:/axis 2-1.6.2-bin/axis2-1.6.2/bin/enterprise.wsdl at com.ibm.wsdl.util.StringUtils.getContentAsInputStream(Unknown Source) ... 6 more


Attribution to: kavin

Possible Suggestion/Solution #1

As stupid as it sounds - have you made any typos in the filename?

I didn't specify full path and it works like charm for me:

c:\(my user)\axis\bin>wsdl2java -uri enterprise.xml

Using AXIS2_HOME:   c:\(my user)\axis
Using JAVA_HOME:    C:\Program Files\Java\jre7
Retrieving document at 'enterprise.xml'.
log4j:WARN No appenders could be found for logger (org.apache.axis2.description.
WSDL11ToAllAxisServicesBuilder).
log4j:WARN Please initialize the log4j system properly.

But the moment I'll specify incorrect file name (say enterprise.wsdl in my case) it throws same error as yours...


Attribution to: eyescream

Possible Suggestion/Solution #2

Well the easiest way to do the same is using Java EE eclipse Ide.

  1. Create a Java Project
  2. Include the WSDL file in the project
  3. Right Click >> Webservices >> Generate Client

Attribution to: Avidev9
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/4800

My Block Status

My Block Content