我正在尝试在Spring WS上设置SOAP,现在我使用这样的文件配置Spring bean:
<?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描述了我的服务。问题是:我可以在这个Spring配置文件中以某种方式使用我的wsdl吗?如果是 - 如何(使用wsdl而不是wsdl)?我知道我可以从wsdl中提取xsd,但是只想使用wsdl。谢谢。
答案 0 :(得分: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”,bean-name是关于如何访问.wsdl的标识符。在上面的例子中:
http://[your_server]/[url_mapping_from_message_dispatcher]/operations.wsdl