Java Web服务客户端(最好的方法)
我有第三方 WSDL,我需要用 Java 为 Web 服务客户端编写代码来调用第三方 WSDL 中的操作。现在,我已经使用 Axis 的 WSDL2JAVA 工具生成了客户端存根,并使用 XMLbean 进行数据绑定。
- 做这个JAVA的最好方法是什么?
- 我读到了 SAAJ,看起来这将是更细粒度的方法?
- 除了使用 WSDL2Java 工具之外,还有其他方法来生成代码吗?也许是另一个选项中的 wsimport 。有什么优点和缺点?
- 有人可以发送有关这些主题的一些优秀教程的链接吗?
- 使用 WSDL2Java 生成代码时我们需要使用哪些选项?
我最初使用了一些基本的东西。现在我有这些选择
C:\axis2-1.5.1\bin>wsdl2java -uri mywsdlurl -o client -p somepackage -d xmlbeans -s -t -ssi
I have a third party WSDL, I need to write code in Java for a web service client to invoke the operations in the third party WSDL. Right now, I have generated the client stub using the WSDL2JAVA tool from Axis and used the XMLbeans for data binding.
- What is the best approach to do this JAVA?
- I read about SAAJ, looks like that will be more granular level of approach?
- Is there any other way than using the WSDL2Java tool, to generate the code. Maybe
wsimport
in another option. What are the pros and cons? - Can someone send the links for some good tutorials on these topics?
- What are the options we need to use while generating the code using the WSDL2Java?
I used some of the basic things initially. Now I have these options
C:\axis2-1.5.1\bin>wsdl2java -uri mywsdlurl -o client -p somepackage -d xmlbeans -s -t -ssi
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我个人不会使用 Axis 2,即使仅用于客户端开发。这就是我远离它的原因:
Axis 仍然存在的唯一原因是 IMO,因为它长期以来一直在 Eclipse 中使用。感谢上帝,这个问题已经在 Eclipse Helios 中修复了,我希望 Axis2 最终能消亡。还有更好的堆栈。
做什么?
是的!更喜欢 JAX-WS 堆栈,例如 CXF 或 JAX-WS RI(您还可以阅读有关 Metro、Metro = JAX-WS RI + WSIT),它们只是更优雅、更简单、更易于使用。就您而言,我将只使用 Java 6 中包含的 JAX-WS RI,因此使用
wsimport
。这是另一个专业人士,有很多(高质量)JAX-WS 教程,例如:
没有选项,请使用
wsimport
:)另请参阅
相关问题
I would personally NOT use Axis 2, even for client side development only. Here is why I stay away from it:
The only reason Axis is still around is IMO because it's used in Eclipse since ages. Thanks god, this has been fixed in Eclipse Helios and I hope Axis2 will finally die. There are just much better stacks.
To do what?
Yes! Prefer a JAX-WS stack like CXF or JAX-WS RI (you might also read about Metro, Metro = JAX-WS RI + WSIT), they are just more elegant, simpler, easier to use. In your case, I would just use JAX-WS RI which is included in Java 6 and thus
wsimport
.That's another pro, there are plenty of (good quality) tutorials for JAX-WS, see for example:
No options, use
wsimport
:)See also
Related questions
我在使用 Spring WS 作为 Web 服务应用程序的客户端方面取得了巨大成功 - 请参阅 http://static.springsource.org/spring-ws/sites/1.5/reference/html/client.html
我的项目使用以下组合:
XMLBeans(从使用 xmlbeans-maven-plugin 的简单 Maven 作业)
Spring WS - 使用 marshalSendAndReceive() 将发送代码减少到一行和接收
some Dozer - 将复杂的 XMLBean 映射到客户端 GUI 的简单 bean
I have had good success using Spring WS for the client end of a web service app - see http://static.springsource.org/spring-ws/sites/1.5/reference/html/client.html
My project uses a combination of:
XMLBeans (generated from a simple Maven job using the xmlbeans-maven-plugin)
Spring WS - using marshalSendAndReceive() reduces the code down to one line for sending and receiving
some Dozer - mapping the complex XMLBeans to simple beans for the client GUI
您可以在此处找到一些与使用 Apache axis2 开发 Web 服务客户端相关的资源。
http:// /today.java.net/pub/a/today/2006/12/13/invoking-web-services-using-apache-axis2.html
下面的帖子很好地解释了如何使用 Apache axis2 开发 Web 服务。
http://www.ibm.com/developerworks/opensource/library/ws- webaxis1/
http://wso2.org/library/136
You can find some resources related to developing web services client using Apache axis2 here.
http://today.java.net/pub/a/today/2006/12/13/invoking-web-services-using-apache-axis2.html
Below posts gives good explanations about developing web services using Apache axis2.
http://www.ibm.com/developerworks/opensource/library/ws-webaxis1/
http://wso2.org/library/136
以下答案中的一些想法:
使用 Axis2 创建 Web 服务的步骤 - 客户端代码
提供了一个 Groovy 客户端调用从 WSDL 生成的 ADB 类的示例。
那里有很多 Web 服务框架......
Some ideas in the following answer:
Steps in creating a web service using Axis2 - The client code
Gives an example of a Groovy client invoking the ADB classes generated from the WSDL.
There are lots of web service frameworks out there...