用 Java 编写 Soap 请求

发布于 2024-09-10 18:43:32 字数 326 浏览 3 评论 0原文

我有一个 wsdl 文件和一个详细文档,其中包含来自 Web 服务提供商的每个请求和响应中的所有元素。我的工作是编写大约 40 个请求并解析相应的响应。

更具体地说,我们的平台提交请求并从服务获取响应,因此对于我来说,作为应用程序开发人员,我只需要编写肥皂请求并将它们作为字符串传递给平台。我还从平台得到字符串响应。

我尝试过 StringBuilder,但它看起来很原始。它必须是一个更好的方法来做到这一点。

我可以将所有请求放入 xml 文档中并以某种方式从中生成请求吗?

或者更好的是,是否可以从 wsdl 文件生成请求?

谢谢,

莎拉

I have a wsdl file and a detailed document about all the elements in every request and response from a web-service provider. My job is to compose around 40 requests and parse corresponding responses.

More specifically, our platform submits the requests and gets responses from the service, so for me, as an application developer, I only need to compose soap requests and pass them as String to the platform. I also get response as String from the platform.

I tried StringBuilder, but it looks pretty primitive. It has to be a better way to do it.

Can I put all the requests in an xml document and somehow generate requests from it?

Or even better, is it possible to generate requests from the wsdl file?

Thanks,

Sarah

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

吖咩 2024-09-17 18:43:32

看一下 wsdl2java 实用程序(有多个版本,一个与 Axis2 一起打包,另一个来自 IBM,等等)。这些可以从您的 WSDL 生成客户端存根,并且应该为您节省大量的工作。

编辑:刚刚意识到这可能需要一些额外的工作,因为您说您的平台提交了请求。生成的代码应该尝试将字符串提交到服务(如果您的 WSDL 指定了该字符串),也许您可​​以修改代码以将字符串传递到您的平台?

JAX-WS 的 wsimport

带有 XFire 的客户端存根

Axis2 的 wsdl2java

IBM 的 wsdl2java

Have a look at the wsdl2java utilities (there are several versions, one packaged with Axis2, another from IBM, etc.). These can generate client stubs from your WSDL, and should save you a considerable amount of work.

EDIT: Just realized that this may require some additional work since you say your platform submits the requests. The generated code should be attempting to submit strings to the service if that is what's specified by your WSDL, perhaps you can modify the code to pass the strings to your platform?

JAX-WS's wsimport

Client stubs w/ XFire

Axis2's wsdl2java

IBM's wsdl2java

亚希 2024-09-17 18:43:32

最简单的方法是soap-ws库: https://github.com/reficio/soap-ws

   SoapClient client = SoapClient.builder()
        .endpointUrl("http://rpc.middleearth.com")
        .build();

   client.post(envelope);

The simplest way is soap-ws library: https://github.com/reficio/soap-ws

   SoapClient client = SoapClient.builder()
        .endpointUrl("http://rpc.middleearth.com")
        .build();

   client.post(envelope);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文