使用 axis 和 Maven 访问 Web 服务
我试图弄清楚如何使用 Axis 访问 Java 中的 Web 服务。
据我了解,这就是我需要做的:
- 使用 WSDL File + Axis 工具生成 Java 文件。
- 编译并打包生成的 Java 文件,然后通过使用这些对象的连接方法来使用这些对象。
在尝试执行此操作时,我陷入了困境:
我从 http://www 中选择了一个随机 Web 服务.service-repository.com/ 我按以下方式使用 axistools-maven-plugin:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>axistools-maven-plugin</artifactId>
<configuration>
<urls>
<!--<url>http://soap.amazon.com/schemas2/AmazonWebServices.wsdl</url>-->
<!--<url>http://ws.xwebservices.com/XWebEmailValidation/V2/XWebEmailValidation.wsdl</url>-->
<url>http://mathertel.de/AJAXEngine/S02_AJAXCoreSamples/OrteLookup.asmx?WSDL</url>
</urls>
<!--<sourceDirectory>${project.build.sourceDirectory}/wsdl</sourceDirectory>-->
<packageSpace>com.company.wsdl</packageSpace>
<testCases>true</testCases>
<serverSide>true</serverSide>
<subPackageByFileName>true</subPackageByFileName>
<outputDirectory>${project.build.directory}/src/generated-sources</outputDirectory>
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
问题是:
我可以成功运行 mvngenerate-sources 并且它确实生成了 Java 文件。但我似乎无法编译这些Java 文件。 当我运行 mvn clean install 时,它给了我一堆编译错误。我缺少哪一步?
Im trying to figure out how to access Web Services in Java using Axis.
As far as I understand, Here's what I need to do :
- Use WSDL File + Axis tools to generate Java files.
- Compile and package generated Java files and then consume those objects by using connection methods on these.
In trying to do this, here's where I'm stuck:
I picked a random Web Service from http://www.service-repository.com/
I used the axistools-maven-plugin in the following manner:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>axistools-maven-plugin</artifactId>
<configuration>
<urls>
<!--<url>http://soap.amazon.com/schemas2/AmazonWebServices.wsdl</url>-->
<!--<url>http://ws.xwebservices.com/XWebEmailValidation/V2/XWebEmailValidation.wsdl</url>-->
<url>http://mathertel.de/AJAXEngine/S02_AJAXCoreSamples/OrteLookup.asmx?WSDL</url>
</urls>
<!--<sourceDirectory>${project.build.sourceDirectory}/wsdl</sourceDirectory>-->
<packageSpace>com.company.wsdl</packageSpace>
<testCases>true</testCases>
<serverSide>true</serverSide>
<subPackageByFileName>true</subPackageByFileName>
<outputDirectory>${project.build.directory}/src/generated-sources</outputDirectory>
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
Here's the issue:
I can successfully run mvn generate-sources and it does generate the Java files. But I can't seem to compile these Java files.
When I run mvn clean install it gives me a bunch of compile errors. What step am I missing ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据您对我的评论之一的回答,我的建议是使用 JAX-WS 实现,例如 JAX -WS RI - 包含在 Java 6 中 - 或 Apache CXF (两者在我看来都差不多)比过时的 Axis 更好的 WS 堆栈)。
下面是一个基于 JAX-WS RI 及其 jaxws-maven 的示例-plugin:
这是一个非常基本的测试用例(maven 项目的一部分),演示了使用生成的类调用 Web 服务:
Based on your answer to one of my comment, my suggestion would be to use a JAX-WS implementation like JAX-WS RI - which is included in Java 6 - or Apache CXF (both are IMO much better WS stacks than the outdated Axis).
Here is an example based on JAX-WS RI and its jaxws-maven-plugin:
And here is a very basic test case (part of the maven project) demonstrating the invocation of the web service using the generated classes: