2015-05-12 71 views
1

我試圖建立SOAP春WS現在我配置Spring豆文件是這樣的:可以在org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition中使用WSDL嗎?

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xmlns:context="http://www.springframework.org/schema/context" 
      xmlns:sws="http://www.springframework.org/schema/web-services" 
      xsi:schemaLocation="http://www.springframework.org/schema/beans 
            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
            http://www.springframework.org/schema/web-services 
            http://www.springframework.org/schema/web-services/web-services-2.0.xsd 
            http://www.springframework.org/schema/context 
            http://www.springframework.org/schema/context/spring-context-3.0.xsd"> 
     <context:component-scan base-package="com.blog.samples.services" /> 
     <sws:annotation-driven /> 
     <!-- 
      Our test service bean 
     --> 
     <bean id="AccountDetailsService" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition" lazy-init="true"> 
     <property name="schemaCollection"> 
     <bean class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection"> 
      <property name="inline" value="true" /> 
      <property name="xsds"> 
      <list> 
       <value>schemas/AccountDetailsServiceOperations.xsd</value> 
      </list> 
      </property> 
     </bean> 
     </property> 
     <property name="portTypeName" value="AccountDetailsService"/> 
     <property name="serviceName" value="AccountDetailsServices" /> 
     <property name="locationUri" value="/endpoints"/> 
    </bean> 
    </beans> 

不幸的是我沒有XSD,我只有這說明我的服務的WSDL。問題是:我可以在這個春天的配置文件中以某種方式使用我的wsdl嗎?如果是 - 如何(使用wsdl而不是wsdl)?我知道我可以從wsdl中提取xsd,但只想使用wsdl。謝謝。

回答

0

你可以使用SimpleWsdl11Definition代替DefaultWsdl11Definition:

通過XML:

<sws:static-wsdl id="operations" location="[your_location]/[your_wsdl].wsdl"/> 

通過Java配置:

@Bean(name = "operations") 
public SimpleWsdl11Definition wsdl11Definition() { 
    SimpleWsdl11Definition s = new SimpleWsdl11Definition(); 
    s.setWsdl(new ClassPathResource("[your_location]/[your_wsdl].wsdl")); 
    return s; 
} 

「ID」 分別豆的名字是如何識別你的.wsdl可以被訪問。在上述情況下:

http://[your_server]/[url_mapping_from_message_dispatcher]/operations.wsdl 
相關問題