如果提供 WSDL,则使用 Spring 的 Web 服务消费示例
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2825583/
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
Example on Web Service Consumption using Spring if provided a WSDL
提问by Hari Charan
Hi Im a newbie to Spring WebServices. I would like to go through a standard example wherein the WSDL is provided as input from Provider. Now how will the client code for this WSDL looks like. Do we need to generate a stub code at client side??
嗨,我是 Spring WebServices 的新手。我想通过一个标准示例,其中 WSDL 作为来自 Provider 的输入提供。现在,此 WSDL 的客户端代码将是什么样子。我们需要在客户端生成存根代码吗??
回答by Espen
I will recommend generating the request and response objects with JAXB from the provider's XSD schemas.
我将建议使用 JAXB 从提供者的 XSD 模式生成请求和响应对象。
You don't need to generate the service classes with Spring WS since it uses a template class to communicate against the WS server. If you're familiar with Spring JDBC or Spring JMS, the template class behaves quite similar to the JMSTemplateand JdbcTemplateclasses.
您不需要使用 Spring WS 生成服务类,因为它使用模板类与 WS 服务器进行通信。如果您熟悉 Spring JDBC 或 Spring JMS,模板类的行为与JMSTemplate和JdbcTemplate类非常相似。
Actually, the Spring WS client doesn't need the WSDL document at all! In addition to XSD schemas, you only need to set the URI property on the WebServiceTemplate bean like this example does:
实际上,Spring WS 客户端根本不需要 WSDL 文档!除了 XSD 模式之外,您只需要像本示例一样在 WebServiceTemplate bean 上设置 URI 属性:
<bean id="webServiceTemplate"
class="org.springframework.ws.client.core.WebServiceTemplate">
<property name="marshaller" ref="marshaller" />
<property name="unmarshaller" ref="marshaller" />
<property name="defaultUri"
value="http://localhost:8081/ws-demo/account-balance-service" />
</bean>
Here's a tutorialthat might give you some answers.
这是一个教程,可能会给你一些答案。
回答by Shameer Kunjumohamed
See if this step by step tutorial on - Web Service Client with Spring-WS - is helpful - at http://justcompiled.blogspot.com/2010/11/web-service-client-with-spring-ws.html
在http://justcompiled.blogspot.com/2010/11/web-service-client-with-spring-ws.html上查看有关 - 带有 Spring-WS 的 Web 服务客户端 - 的分步教程是否有帮助

