从 WSDL 编写 Web 服务客户端
我在某处的应用程序服务器上发布了 WSDL。我想编写一个使用 WSDL 发送请求和接收响应的 Web 服务客户端。我以前没有这样做过,并且大多数教程都假设您拥有 Web 服务的代码。
最直接的方法是什么?
I have a WSDL published on an application server somewhere. I would like to write a webservice client that uses the WSDL to send requests and recieve responses. I have not done this before, and most of the tutorials assume you have the code for the webservice.
What is the most straight forward way to do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 jax-ws 为 Web 服务端点生成客户端。有一个名为“wsimport”的工具可以为您完成此操作。
给定一个 wsdl,它将生成您使用 Java 以编程方式调用 Web 服务所需的所有客户端工件。
请参阅此处了解更多详细信息 - http://download.oracle .com/javase/6/docs/technotes/tools/share/wsimport.html
Use jax-ws to generate a client for the web service end point. There is a tool called "wsimport" which will do that for you.
Given a wsdl, it will generate all the client artifacts that you need to call the web service programmatically using Java.
See here for more details- http://download.oracle.com/javase/6/docs/technotes/tools/share/wsimport.html
发出这些请求的一种方法是发出 HTTP 请求,并在请求正文中传递适当的 Web 服务 XML。我们需要定期对 Salesforce.com 执行此操作,因为它可以使用的 WSDL 相对有限,因此我们需要找到一种简单的方法来查看这些请求的内容应该是什么。既然您已经编写了网络服务,我假设您知道需要发送给它什么,但如果不知道 SoapUI 是一个非常宝贵的工具 — 它可以使用 WSDL 并生成示例请求,然后您可以填写并启动这些示例请求来测试 Web 服务。特别是对于 Java,您需要找到 WSDL2Java 工具来生成可用于轻松调用服务的类。
One way to make these requests is to make an HTTP request passing the appropriate webservice XML in the body of the request. We need to do this regularly with Salesforce.com as it's relatively limited with regards to the WSDLs that it can consume, and so we need to find an easy way to see what the contents of those requests should be. Since you've written the webservice I assume you know what you need to send to it, but if not SoapUI is an invaluable tool — it can consume WSDLs and generate example requests which you can then fill in and fire off to test the webservice also. For Java in particular, you'll want to find the WSDL2Java tool to generate classes you can use to call the service with ease.