我是Web服务新手,Axis 2和maven,但我需要它才能获得硕士论文。我已成功创建并测试了本教程中的SOAP Web服务:Web service Tutorial
现在我想创建一个MavenProject,我可以在本教程中创建此服务的客户端类和存根:Client Tutorial使用 axis2-wsdl2code-maven -plugin 即可。这一代工作正常,但每次Stub级都会出错。
错误是: org.apache.axis2.xmlbeans无法解析为类型 。这是我在Stub中遇到的唯一错误。这是一个方法,出现错误(第5行 org.apache.axis2.xmlbeans.XmlBeansXMLReader ):
private org.apache.axiom.om.OMElement toOM(
final com.mycompany.axisservice3.SayOnlyOneHelloDocument param)
throws org.apache.axis2.AxisFault {
org.apache.axiom.om.OMXMLParserWrapper builder = org.apache.axiom.om.OMXMLBuilderFactory.createOMBuilder(new javax.xml.transform.sax.SAXSource(
new org.apache.axis2.xmlbeans.XmlBeansXMLReader(param,
_xmlOptions), new org.xml.sax.InputSource()));
try {
return builder.getDocumentElement(true);
} catch (java.lang.Exception e) {
throw org.apache.axis2.AxisFault.makeFault(e);
}
}
其余生成的类没有错误,似乎没问题。
所以我认为它必定是依赖问题,因为系统找不到包 org.apache.axis2.xmlbeans 。我正在使用最新版本的Apache Axis 2(1.7.1)和Maven 2.所以我已经调整了从视频到Maven Repository-Website的最新版本的依赖关系。
Axis2 Runtime成功加载并在eclipse中配置。路径和环境变量已设置。
这是我目前为客户提供的POM:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.andy</groupId>
<artifactId>AxisService3Client</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>target/generated-sources/axis2/wsdl2code/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-wsdl2code-maven-plugin</artifactId>
<version>1.7.1</version>
<executions>
<execution>
<goals>
<goal>wsdl2code</goal>
</goals>
<configuration>
<unpackClasses>true</unpackClasses>
<databindingName>xmlbeans</databindingName>
<packageName>org.andy.ws</packageName>
<wsdlFile>src/main/resources/wsdl/HelloService.wsdl</wsdlFile>
<syncMode>sync</syncMode>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-kernel</artifactId>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-api</artifactId>
<version>1.2.18</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-impl</artifactId>
<version>1.2.18</version>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
<version>1.6.3</version>
</dependency>
<dependency>
<groupId>org.apache.neethi</groupId>
<artifactId>neethi</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-local</artifactId>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-http</artifactId>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.schema</groupId>
<artifactId>XmlSchema</artifactId>
<version>1.4.7</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
非常感谢你的帮助!
答案 0 :(得分:2)
添加以下依赖项:
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-xmlbeans</artifactId>
<version>1.7.1</version>
</dependency>
答案 1 :(得分:0)
我必须在下面添加依赖项,
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-kernel</artifactId>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-xmlbeans</artifactId>
<version>1.7.1</version>
</dependency>
然后项目成功构建。