我想在 C 代码中使用网络服务。我正在努力做一个客户。我需要做 Axis2java 所做的事情并从 wsdl 文件生成类。 我发现 Axis2c 从 wsdl 文件生成 (.c) 文件。 我是从here下载的。解压它。我为 AXIS2C_HOME 创建了环境变量,并创建了 AXIS2C_CLASSPATH。 但我无法让它发挥作用。
当我输入此命令时:
WSDL2C -uri -ss -sd -d none -u -f -o
我收到此错误:
echo off Error: Could not find or load main class org.apache.axis2.wsdl.WSDL2C
我该如何解决这个问题。请告诉我如何正确使用这个 Axis2c 工具。
提前谢谢您。
@loentar:我安装了 Axis2/Java 并为其设置了环境变量。现在我运行 wsdl2c.bat 我得到这个:
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.
之后我运行此命令:
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.
我能做什么? 顺便说一下,我使用的是 Windows 8。
最佳答案
除了 Axis2/C 之外,您还必须安装 Axis2/Java。
AXIS2_HOME
必须指向 Axis2/Java 安装。
详情请见README代码生成器。
创建和编译客户端的完整命令列表是:
# create stubs
sh $AXIS2C_HOME/bin/tools/wsdl2c/WSDL2C.sh -uri Calculator.wsdl -u -uw
# implement main() in src/your_client.c
# see samples/codegen/client/calculator for example
# compile and link client
gcc -o calculator_client src/*.c -I$AXIS2C_HOME/include/axis2-1.6.0 -L$AXIS2C_HOME/lib -laxutil -laxis2_axiom -laxis2_parser -laxis2_engine -lpthread -laxis2_http_sender -laxis2_http_receiver -ldl -Wl,--rpath -Wl,$AXIS2C_HOME/lib
关于c - 如何使用Axis2c从WSDL文件生成C文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28063026/