cweb-serviceswsdlaxis2cwsdl2code

How to use Axis2c to generate C files from WSDL file


I want to use a webservice in C code. I am trying to make a client. I need something to do what Axis2java does and generates the classes from a wsdl files. I found that Axis2c makes (.c) files generated from wsdl file. I downloaded it from here . unzipped it. I created the environment variable for AXIS2C_HOME and I created AXIS2C_CLASSPATH. but I can't make it work.

when I type this command :

WSDL2C -uri -ss -sd -d none -u -f -o

I get this error :

echo off
Error: Could not find or load main class org.apache.axis2.wsdl.WSDL2C

how can I solve this problem. and please tell me how to use this Axis2c tool properly.

Thank you in advance.

@loentar : I installed Axis2/Java and I set the environment variable for it. now I run the wsdl2c.bat I get this :

E:\dev\Tools\axis2c-bin-1.6.0-win32\bin\tools\wsdl2c>WSDL2C.bat

E:\dev\Tools\axis2c-bin-1.6.0-win32\bin\tools\wsdl2c>echo off
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)
where options include:
    -d32          use a 32-bit data model if available
    -d64          use a 64-bit data model if available
    -server       to select the "server" VM
                  The default VM is server.

    -cp 
    -classpath 
                  A ; separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
    -D=
                  set a system property
    -verbose:[class|gc|jni]
                  enable verbose output
    -version      print product version and exit
    -version:
                  require the specified version to run
    -showversion  print product version and continue
    -jre-restrict-search | -no-jre-restrict-search
                  include/exclude user private JREs in the version search
    -? -help      print this help message
    -X            print help on non-standard options
    -ea[:...|:]
    -enableassertions[:...|:]
                  enable assertions with specified granularity
    -da[:...|:]
    -disableassertions[:...|:]
                  disable assertions with specified granularity
    -esa | -enablesystemassertions
                  enable system assertions
    -dsa | -disablesystemassertions
                  disable system assertions
    -agentlib:[=]
                  load native agent library , e.g. -agentlib:hprof
                  see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:[=]
                  load native agent library by full pathname
    -javaagent:[=]
                  load Java programming language agent, see java.lang.instrument

    -splash:
                  show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for m
ore details.

after that I run this command :

E:\dev\Tools\axis2c-bin-1.6.0-win32\bin\tools\wsdl2c>WSDL2C.bat -uri hello.wsdl
-u -uw

E:\dev\Tools\axis2c-bin-1.6.0-win32\bin\tools\wsdl2c>echo off
Unrecognized option: -uri
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

what can I do ? I'm using windows 8 by the way.


Solution

  • I set the envinroment variable for JAVA_HOME, AXIS2_HOME, AXIS2C_HOME, and added their lib folder to CLASSPATH. after running this command: WSDL2C.bat -uri hello.wsdl -u -uw I got this message:

    echo off 
    Error: Could not find or load main class org.apache.axis2.wsdl.WSDL2C
    

    I found the solution myself. :) I double checked if I had created the environment variable for AXIS2_HOME and I saw that it is there, correctly. in spite of it's existence I tried to set it again in command prompt. so I typed:

    SET AXIS2_HOME=E:\dev\Tools\axis2-1.6.2
    

    then I typed the command for WSDL2C code generator:

    WSDL2C.bat -uri hello.wsdl -u -uw
    

    And BAM ! it worked properly. Now I can generate C files from WSDL file.