如何创建soap客户端?

发布于 2024-12-09 21:57:36 字数 166 浏览 1 评论 0原文

我正在运行 SOAP 服务器。我需要为服务器编写一个 SOAP 客户端。你能建议 eclipse 中的插件或者给我与此相关的 URL 吗?

您能给我提供任何示例 SOAP 客户端代码吗?

我的 SOAP 客户端应该使用复杂对象作为 SOAP 服务器中公开的 SOAP 函数的参数/参数。

I have SOAP server running. I need to write a SOAP client for the server. Can you please suggest plugin in eclipse or give me the URL related to this?

can you please provide me it you have any sample SOAP Client code?

My SOAP client should use complex objects as parmeter/arguments for the SOAP function which is exposed in the SOAP server.

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

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

发布评论

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

评论(6

尤怨 2024-12-16 21:57:37

假设 Java:

1.- 执行:

wsimport -keep -p myClient url_to_wsdl

其中 myClient 将是包含生成的客户端工件的文件夹。 url_to_wsdl WSDL 的 URL。

2.- 使用包含以下代码的方法创建客户端类:

    YourServiceClass service = new YourServiceClass();
    YourEndpointClass port = service.getPort();
    YourRequestClass request = new YourRequestClass();
    YourMessageClass message = new YourMessageClass(); //In case you have it
    message.setParam1(param1); //depending on your message
    message.setParam2(param2);

    request.setMessage(message);
    YourResponseClass response = port.ServiceOperation(request); //This call locks execution

    System.out.println(response.getMessage().getResponse());
  • YourServiceClass 是生成的扩展 javax.xml.ws.Service 的工件。

  • YourEndpointClass 可以在调用 super.getPort() 的操作中的 YourServiceClass 中看到;

  • YourRequestClassYourResponseClass 将取决于请求和响应消息的管理方式。

  • YourMessageClass 将是您的消息的包装类(取决于 WSDL)。

所有您的*类必须由wsimport生成并导入到您的客户端类。
使用 wsimport 中的 -keep 标志,您将能够查看 .java 文件并确定完成此代码所需的类。

Assuming Java:

1.- Execute:

wsimport -keep -p myClient url_to_wsdl

Where myClient will be a folder with the generated client's artifacts. url_to_wsdl the url to your WSDL.

2.- Create a client class with a method with the following code:

    YourServiceClass service = new YourServiceClass();
    YourEndpointClass port = service.getPort();
    YourRequestClass request = new YourRequestClass();
    YourMessageClass message = new YourMessageClass(); //In case you have it
    message.setParam1(param1); //depending on your message
    message.setParam2(param2);

    request.setMessage(message);
    YourResponseClass response = port.ServiceOperation(request); //This call locks execution

    System.out.println(response.getMessage().getResponse());
  • YourServiceClass is the generated artifact the extends javax.xml.ws.Service.

  • YourEndpointClass can be seen in YourServiceClass in an operation that calls super.getPort();

  • YourRequestClass and YourResponseClass will depend on how is managed the Request and Response message.

  • YourMessageClass would be a wrapper class for your message (depending on WSDL).

All Your* classes must have been generated by wsimport and imported to your client class.
With the flag -keep in wsimport you'll be able to see the .java files and determine which classes you require to complete this code.

三生池水覆流年 2024-12-16 21:57:37

您的问题非常模糊,因此请使用 Apache CXF 并按照本教程进行操作:

  1. 这是最新的(2011)文章: 使用 Apache CXF 或 GlassFish Metro 创建 SOAP 客户端
  2. 如何使用 CXF 和 Java 创建 WSDL 优先的 SOAP 客户端Maven
  3. 此演示说明了 Apache CXF 对 SOAP 标头的支持

另外,您也可以使用 Apache AXIS2。

Your question is very vague, so use Apache CXF and follow this tutorial:

  1. This is the most recent (2011) writeup: Creating a SOAP client with either Apache CXF or GlassFish Metro
  2. How to create a WSDL-first SOAP client in Java with CXF and Maven and
  3. This demo illustrates Apache CXF's support for SOAP headers

Other wise, you can also use Apache AXIS2.

梦里梦着梦中梦 2024-12-16 21:57:37

这里有一份关于如何创建一个的详细教程:Java 中的 SOAP 客户端

here's a detailed tutorial on how you can create one : SOAP Client in Java

何以畏孤独 2024-12-16 21:57:37

将您的 eclipse 更新到最新版本(不过我也看到它与 Eclipse Europa 3.3.2 一起工作:))。转到新建项目向导,在Web 服务下选择Web 服务客户端,单击“下一步”,然后提供 Web 服务的 wsdl 文件位置。 Eclipse 将自动为您生成 Web 服务存根。

Update your eclipse to newest version (I have seen it working with Eclipse Europa 3.3.2 also though :) ). Go to new project wizard and under Web Service select Web Service Client, click next and then give wsdl file location of your web service. Eclipse will automatically generate web service stubs for you.

紅太極 2024-12-16 21:57:37

这是一个有点宽泛的问题。从我的角度来看,我建议使用 Apache CXF: http://cxf.apache.org/

有非常好的示例,您可以定义 WSDL 并生成服务器和客户端代码。还有 Maven 插件可以自动为你完成这项工作。嵌入由 WSDL 描述的现有 Web 服务也是可能的。

但这更多的是一个要求和品味的问题。

可以在这里找到替代方案: http://java-source.net/open-源/网络服务工具

Thats pretty much a little bit broad question. From my point of view i would suggest using Apache CXF: http://cxf.apache.org/

There are pretty good samples and you define a WSDL and generate the server as well as the client code. There are also maven plugins which do this JOB automatically for you. Embedding an existent web-service described by an WSDL is also possible.

But however this is more a matter of requirements and taste.

Alternatives may be found e.g. here: http://java-source.net/open-source/web-services-tools

黎夕旧梦 2024-12-16 21:57:37

你可以看看这个--> https://github.com/devashish234073/SOAP_GUI_PHP/blob/master/README。 MD
这是一个简单的 php SOAP 客户端。

使用与 php 相同的逻辑 [home.php],我还添加了 java版本

You can have a look at this --> https://github.com/devashish234073/SOAP_GUI_PHP/blob/master/README.md
This is a simple SOAP client in php.

Using same logic as the php one [home.php], I have also added the java version

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