【发布时间】:2012-12-10 15:31:19
【问题描述】:
我想知道是否可以使用 Spring Web Services 从 WSDL 文件创建 Web Services 客户端。
我的意思是从 WSDL 开始,我暂时没有任何 XSD。
但我已经阅读了 Josh Long 的“Spring Recipes A Problem-Solution Approach”、Hamidreza Sattari 的“Spring Web Services 2 Cookbook”以及教程本身 (6. Using Spring Web Services on the Client),但没有提及此功能。
我还阅读了其他帖子,例如 Webservice-Client: Common approach with Spring WS, JAXB and just one WSDL file? 或 Spring-ws client from WSDL(在 stackoverflow 上),但没有任何进一步的结果。
我什至在 Spring 论坛上问过这个问题,但阅读超过 60 次后没有回复:Is it possible to create a WS-client from WSDL file using SWS? (It seems not)
也许这是不可能的。
谢谢。
【问题讨论】:
-
你说“创建一个 WS 客户端”是什么意思?因为您可以使用 WebServiceTemplate 类在 SOAP 消息中包装您想要的任何内容。我怀疑您真的在考虑创建客户端可以使用的 POJO 类。如果您在 WSDL 中有
type部分,那么您可以通过 XJC 编译器运行该 WSDL 并获取您的类。 -
¿没有进一步的结果?你在这个过程中发现了哪些错误?你试过什么?请显示一些代码。
-
谢谢@kdgregory,我真正的意思是我想Send and receive POJOs: marshalling and unmarshalling,所以我需要XJC。也感谢 Alfabravo 对我的问题表现出兴趣。我唯一的问题是像 kdgregory 所说的那样生成 POJO。我可以send a WebServiceMessage with WebServiceTemplate,但静态字符串消息(用于使用 StringReader 创建 StreamSource)不是我想要的。
标签: java spring wsdl spring-ws