使用axis 1.4 生成金蝶EAS webservice客户端

Posted lhjszz

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用axis 1.4 生成金蝶EAS webservice客户端相关的知识,希望对你有一定的参考价值。

最近开发一个金蝶EAS webservice 接口。在生成客户端的时候遇到了一点小麻烦,记录一下解决过程,以备参考。

服务端开发完成后,要开发客户端,首先想到了axis这个古老的项目。下载了axis2 1.7.9 的二进制包、解压。

打开一个cmd窗口,输入命令 bin\\wsdl2java.bat -uri http://xxx:6888/ormrpc/services/WSSyncApiFacade?wsdl ,直接报错:

log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.apache.axis2.wsdl.codegen.CodeGenerationException: Error parsing WSDL
        at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.<init>(CodeGenerationEngine.java:177)
        at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:50)
        at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:24)
Caused by: org.apache.axis2.AxisFault: Part \'fault\' of fault message \'{http://xxxx:6888/ormrpc/services/WSSyncApiFacade}WSInvokeException\' must be defined with \'element=QName\' and not \'type=QName\'
        at org.apache.axis2.description.WSDL11ToAxisServiceBuilder.addQNameReference(WSDL11ToAxisServiceBuilder.java:1375)
        at org.apache.axis2.description.WSDL11ToAxisServiceBuilder.populateBinding(WSDL11ToAxisServiceBuilder.java:901)
        at org.apache.axis2.description.WSDL11ToAxisServiceBuilder.populateEndpoint(WSDL11ToAxisServiceBuilder.java:547)
        at org.apache.axis2.description.WSDL11ToAxisServiceBuilder.populateEndpoints(WSDL11ToAxisServiceBuilder.java:499)
        at org.apache.axis2.description.WSDL11ToAxisServiceBuilder.populateService(WSDL11ToAxisServiceBuilder.java:370)
        at org.apache.axis2.description.WSDL11ToAllAxisServicesBuilder.populateAllServices(WSDL11ToAllAxisServicesBuilder.java:107)
        at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.<init>(CodeGenerationEngine.java:171)
        ... 2 more



猜测是axis版本的问题,经过一番查询,发现了下面一段描述 ,这是解决问题的关键

According to the specification, fault and header message parts must be
defined as document/literal, even if the body is defined as RPC style.
Axis 1.x did not follow the specification in this case. If the body
was defined as RPC style, it also used RPC for the fault and header
definitions.

Axis 1.x 没有遵循规范:fault and header message parts must be defined as document/literal,

金蝶eas8.5 的webservice使用的是axis1.4构建。

知道了问题的原因,解决起来就简单了,直接切换到axis1.4 生成。

懒得写脚本了,直接使用maven下载axis的包,在idea下运行。

maven引入相关包

<dependency>
			<groupId>org.apache.axis</groupId>
			<artifactId>axis</artifactId>
			<version>1.4</version>
		</dependency>
		<dependency>
			<groupId>org.apache.axis</groupId>
			<artifactId>axis-jaxrpc</artifactId>
			<version>1.4</version>
		</dependency>
		<dependency>
			<groupId>org.apache.axis</groupId>
			<artifactId>axis-saaj</artifactId>
			<version>1.4</version>
		</dependency>
		<dependency>
			<groupId>wsdl4j</groupId>
			<artifactId>wsdl4j</artifactId>
			<version>1.4</version>
		</dependency>

reimport maven配置文件后,在External Libraries 下找到axis的jar,双击打开包中的WSDL2Java类

右键运行该类,弹出运行参数对话框:

 

查询参数说明 ,在Program arguments 中填写参数:

-o .\\generated\\ -u http://xxxx:6888/ormrpc/services/WSSyncApiFacade?wsdl  -pcom.abc.eas.syncapi

基中,-o后面是生成类的输出路径,-u后面是wsdl的url -p是生成的包名

然后Use classpath of module 直接选择当前的模块。

点击运行按钮,生成客户端。

 

 

 

参考文档 :

https://stackoverflow.com/questions/65832248/apache-axis-cannot-find-wsdl2java-class

https://jira.atlassian.com/browse/JRASERVER-12152

以上是关于使用axis 1.4 生成金蝶EAS webservice客户端的主要内容,如果未能解决你的问题,请参考以下文章

金蝶EAS安装后检测更新要多久

金蝶eas如何关闭自动更新

金蝶苍穹初级,,星空初级,, EAS初级认证有什么区别

金蝶EAS系统进不去

金蝶EAS无法启动,点击后在进程里闪一下就没了。

金蝶EAS,总是正在检测是不是有新版本,怎么办