如果提供了WSDL,则使用Spring的Web服务消耗示例

时间:2010-05-13 09:16:49

标签: spring spring-ws

嗨,我是Spring WebServices的新手。我想通过一个标准示例,其中WSDL作为Provider的输入提供。 现在,这个WSDL的客户端代码将如何呈现。我们是否需要在客户端生成存根代码?

2 个答案:

答案 0 :(得分:9)

我建议使用提供程序的XSD架构使用JAXB生成请求和响应对象。

您不需要使用Spring WS生成服务类,因为它使用模板类与WS服务器进行通信。如果您熟悉Spring JDBC或Spring JMS,则模板类的行为与JMSTemplateJdbcTemplate类非常相似。

实际上,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>

这是tutorial,可能会给你一些答案。

答案 1 :(得分:3)

http://justcompiled.blogspot.com/2010/11/web-service-client-with-spring-ws.html

查看这个有关Spring-WS的Web服务客户端的分步教程是否有用