当前位置: 首页 > 工具软件 > axis2c > 使用案例 >

Axis2C:由WSDL自动生成服务端及客户端 C代码

姜鸿畴
2023-12-01

   1. 编写好WSDL文件。

   2. 编写生成代码脚本WSDL2C.sh

************************************************************

[root@localhost code]# cat /axis2c-1.6/bin/tools/wsdl2c/WSDL2C.sh

#!/bin/sh

 

export AXIS2_HOME=/axis2_java

for f in $AXIS2_HOME/lib/*.jar

do

  AXIS2_CLASSPATH=$AXIS2_CLASSPATH:$f

done

export AXIS2_CLASSPATH

 

echo the classpath $AXIS2_CLASSPATH

java -classpath $AXIS2_CLASSPATH org.apache.axis2.wsdl.WSDL2C $*

************************************************************

注意脚本 中AXIS2_HOME为Axis2 JAVA的目录。非Axis2C!!!

 

   3. 执行WSDL2C.sh:

#/axis2c-1.6/bin/tools/wsdl2c/WSDL2C.sh -uri Calculator.wsdl -u -ss -sd

********************************************************************************

 

[root@localhost code]# /axis2c-1.6/bin/tools/wsdl2c/WSDL2C.sh -uri Calculator.wsdl -u -ss -sd

the classpath :/axis2_java/lib/activation-1.1.jar:/axis2_java/lib/antlr-2.7.7.jar:/axis2_java/lib/axiom-api-1.2.10.jar:/axis2_java/lib/axiom-dom-1.2.10.jar:/axis2_java/lib/axiom-impl-1.2.10.jar:/axis2_java/lib/axis2-adb-1.5.3.jar:/axis2_java/lib/axis2-adb-codegen-1.5.3.jar:/axis2_java/lib/axis2-ant-plugin-1.5.3.jar:/axis2_java/lib/axis2-clustering-1.5.3.jar:/axis2_java/lib/axis2-codegen-1.5.3.jar:/axis2_java/lib/axis2-corba-1.5.3.jar:/axis2_java/lib/axis2-fastinfoset-1.5.3.jar:/axis2_java/lib/axis2-java2wsdl-1.5.3.jar:/axis2_java/lib/axis2-jaxbri-1.5.3.jar:/axis2_java/lib/axis2-jaxws-1.5.3.jar:/axis2_java/lib/axis2-jibx-1.5.3.jar:/axis2_java/lib/axis2-json-1.5.3.jar:/axis2_java/lib/axis2-kernel-1.5.3.jar:/axis2_java/lib/axis2-metadata-1.5.3.jar:/axis2_java/lib/axis2-mtompolicy-1.5.3.jar:/axis2_java/lib/axis2-saaj-1.5.3.jar:/axis2_java/lib/axis2-soapmonitor-servlet-1.5.3.jar:/axis2_java/lib/axis2-spring-1.5.3.jar:/axis2_java/lib/axis2-transport-http-1.5.3.jar:/axis2_java/lib/axis2-transport-local-1.5.3.jar:/axis2_java/lib/axis2-xmlbeans-1.5.3.jar:/axis2_java/lib/bcel-5.1.jar:/axis2_java/lib/commons-codec-1.3.jar:/axis2_java/lib/commons-fileupload-1.2.jar:/axis2_java/lib/commons-httpclient-3.1.jar:/axis2_java/lib/commons-io-1.4.jar:/axis2_java/lib/commons-logging-1.1.1.jar:/axis2_java/lib/geronimo-annotation_1.0_spec-1.1.jar:/axis2_java/lib/geronimo-jaxws_2.1_spec-1.0.jar:/axis2_java/lib/geronimo-jta_1.1_spec-1.1.jar:/axis2_java/lib/geronimo-saaj_1.3_spec-1.0.1.jar:/axis2_java/lib/geronimo-stax-api_1.0_spec-1.0.1.jar:/axis2_java/lib/geronimo-ws-metadata_2.0_spec-1.1.2.jar:/axis2_java/lib/httpcore-4.0.jar:/axis2_java/lib/jalopy-1.5rc3.jar:/axis2_java/lib/jaxb-api-2.1.jar:/axis2_java/lib/jaxb-impl-2.1.7.jar:/axis2_java/lib/jaxb-xjc-2.1.7.jar:/axis2_java/lib/jaxen-1.1.1.jar:/axis2_java/lib/jettison-1.0-RC2.jar:/axis2_java/lib/jibx-bind-1.2.1.jar:/axis2_java/lib/jibx-run-1.2.1.jar:/axis2_java/lib/juli-6.0.16.jar:/axis2_java/lib/log4j-1.2.15.jar:/axis2_java/lib/mail-1.4.jar:/axis2_java/lib/mex-1.5.3-impl.jar:/axis2_java/lib/neethi-2.0.4.jar:/axis2_java/lib/regexp-1.2.jar:/axis2_java/lib/tribes-6.0.16.jar:/axis2_java/lib/woden-api-1.0M8.jar:/axis2_java/lib/woden-impl-dom-1.0M8.jar:/axis2_java/lib/wsdl4j-1.6.2.jar:/axis2_java/lib/wstx-asl-3.2.9.jar:/axis2_java/lib/xalan-2.7.0.jar:/axis2_java/lib/xercesImpl-2.8.1.jar:/axis2_java/lib/xmlbeans-2.3.0.jar:/axis2_java/lib/xml-resolver-1.2.jar:/axis2_java/lib/XmlSchema-1.4.3.jar

Retrieving document at 'Calculator.wsdl'.

log4j:WARN No appenders could be found for logger (org.apache.axis2.description.WSDL11ToAllAxisServicesBuilder).

log4j:WARN Please initialize the log4j system properly.

[root@localhost code]# ll

total 16

-rw-r--r-- 1 root root 8014 Apr 28 12:11 Calculator.wsdl

drwxr-xr-x 2 root root 4096 Apr 28 12:12 resources/

drwxr-xr-x 2 root root 4096 Apr 28 12:12 src/

 

 

[root@localhost code]# ll src/

total 332

-rw-r--r-- 1 root root 30432 Apr 28 12:12 adb_add.c

-rw-r--r-- 1 root root  9692 Apr 28 12:12 adb_add.h

-rw-r--r-- 1 root root 20068 Apr 28 12:12 adb_addResponse.c

-rw-r--r-- 1 root root  8416 Apr 28 12:12 adb_addResponse.h

-rw-r--r-- 1 root root 30432 Apr 28 12:12 adb_div.c

-rw-r--r-- 1 root root  9692 Apr 28 12:12 adb_div.h

-rw-r--r-- 1 root root 20068 Apr 28 12:12 adb_divResponse.c

-rw-r--r-- 1 root root  8416 Apr 28 12:12 adb_divResponse.h

-rw-r--r-- 1 root root 30432 Apr 28 12:12 adb_mul.c

-rw-r--r-- 1 root root  9692 Apr 28 12:12 adb_mul.h

-rw-r--r-- 1 root root 20068 Apr 28 12:12 adb_mulResponse.c

-rw-r--r-- 1 root root  8416 Apr 28 12:12 adb_mulResponse.h

-rw-r--r-- 1 root root 30432 Apr 28 12:12 adb_sub.c

-rw-r--r-- 1 root root  9692 Apr 28 12:12 adb_sub.h

-rw-r--r-- 1 root root 20068 Apr 28 12:12 adb_subResponse.c

-rw-r--r-- 1 root root  8416 Apr 28 12:12 adb_subResponse.h

-rw-r--r-- 1 root root  2681 Apr 28 12:12 axis2_skel_Calculator.c

-rw-r--r-- 1 root root  2679 Apr 28 12:12 axis2_skel_Calculator.h

-rw-r--r-- 1 root root 14048 Apr 28 12:12 axis2_svc_skel_Calculator.c

-rw-r--r-- 1 root root   268 Apr 28 12:12 build.sh

[root@localhost code]# ll resources/

total 4

-rw-r--r-- 1 root root 808 Apr 28 12:12 services.xml

 

*******************************************************

4. 生成客户端代码命令:

/axis2c-1.6/bin/tools/wsdl2c/WSDL2C.sh -uri adtDeviceService.wsdl -u

 类似资料: