java 使用 wsdl 文件生成肥皂请求消息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12821914/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
generate a soap request message using wsdl file
提问by Gayan Dhanushka
I have a wsdl of a web service with me. I want to generate the structure of the soap request message using this wsdl file. What would be the best way to generate a sample soap request message using the wsdl file? I want this to be done using a java based technology.
我有一个 Web 服务的 wsdl。我想使用这个 wsdl 文件生成soap请求消息的结构。使用 wsdl 文件生成示例 soap 请求消息的最佳方法是什么?我希望使用基于 Java 的技术来完成此操作。
Thanks
谢谢
回答by davidfmatheson
I would recommend staring with a tool like SoapUIto generate raw SOAP requests. If you want to generate your SOAP requests with Java, then the general process is:
我建议使用像SoapUI这样的工具来生成原始 SOAP 请求。如果你想用 Java 生成你的 SOAP 请求,那么一般的过程是:
回答by wallenborn
Use one of the popular web service frameworks (Axis or CXF or whatever) and let it autogenerate the classes for you. See for example herefor documentation on how to do this on the command line, and herefor the corresponding maven plugin for CXF. Axis is very similar, i believe.
使用流行的 Web 服务框架之一(Axis 或 CXF 或其他),让它为您自动生成类。例如,见这里了解如何做到这一点的命令行和文件在这里为CXF相应的Maven插件。我相信 Axis 非常相似。
Whenever i need sample xml soap messages, i do this for server and client side, then start the dummy server with mvn tomcat:run
and on the client side i construct the message in Java and let the framework log the message for me. Sounds more complicated than it actually is, especially considering that you probably need more than just one sample message and usually end up implementing your own dummy server anyway.
每当我需要示例 xml soap 消息时,我都会为服务器端和客户端执行此操作,然后在客户端启动虚拟服务器mvn tomcat:run
并在客户端我用 Java 构建消息并让框架为我记录消息。听起来比实际复杂,特别是考虑到您可能需要的不仅仅是一个示例消息,而且通常最终还是要实现自己的虚拟服务器。