2010-05-13 63 views
8

嗨,我是Spring WebServices的新手。我想通過一個標準示例,其中WSDL作爲Provider的輸入提供。 現在,該WSDL的客戶端代碼如何看起來像。我們是否需要在客戶端生成存根代碼?使用Spring的Web服務消耗示例(如果提供了WSDL)

+0

你;在http://static.springsource.org/spring-ws讀過的客戶文檔/sites/1.5/reference/html/client.html,對嗎? – skaffman 2010-05-13 09:19:21

+0

是的,我已經經歷過,但是這並不回答我的要求 – 2010-05-13 11:27:03

+0

該示例根本不包含WSDL URL。這是簡單的String消息,但我的項目包含包裝器請求對象的WSDL – 2010-05-13 11:28:11

回答

9

我會建議使用JAXB從提供者的XSD模式生成請求和響應對象。

您不需要使用Spring WS生成服務類,因爲它使用模板類來與WS服務器進行通信。如果您熟悉Spring JDBC或Spring JMS,則模板類的行爲與JMSTemplateJdbcTemplate類非常相似。

實際上,Spring WS客戶端根本不需要WSDL文檔!除了XSD模式,你只需要像這個例子,設置在WebServiceTemplate豆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這可能會給你一些答案。