spring-ws错误创建动态wsdl

时间:2011-06-16 09:16:19

标签: java web-services spring wsdl spring-ws

我想通过spring-ws自动创建我的wsdl,然后将下面的代码插入到我的app上下文文件中,但是我收到了错误;

“找不到元素[dynamic-wsdl]的BeanDefinitionParser”

这意味着什么,我该怎么办? TNX

<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">


<bean id="payloadMapping"
       class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
    <property name="defaultEndpoint" ref="inferenceEndPoint" />
    <property name="interceptors">
        <list>
            <ref local="validatingInterceptor" />
            <ref local="payLoadInterceptor" />
        </list>
    </property>
</bean>

<bean id="payLoadInterceptor"
    class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor" />

<bean id="validatingInterceptor"
    class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
    <description>
        This interceptor validates the incoming
        message contents
        according to the 'Request.xsd' XML
        Schema file.
    </description>
    <property name="schema" value="/WEB-INF/schemas/Request.xsd" />
    <property name="validateRequest" value="true" />
    <property name="validateResponse" value="false" />
</bean>

<bean id="inferenceEndPoint" class="com.mywebsite.ws.web.InferenceEndPoint">
    <property name="messageService" ref="messageService" />
</bean>

<bean id="messageService" class="com.mywebsite.ws.service.MessageService">
    <property name="inferenceService" ref="inferenceService" />
</bean>

<bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema">
    <property name="xsd" value="/WEB-INF/schemas/Request.xsd" />
</bean>

  <sws:dynamic-wsdl id="mtwsdl"
    portTypeName="mtWS"
    locationUri="http://localhost:8080/mws/">
<sws:xsd location="/WEB-INF/schemas/Request.xsd" />
   </sws:dynamic-wsdl>
<bean id="inferenceService" class="com.mywebsite.ws.im.InferenceService">
    <property name="webServiceConfiguration" ref="playerConfiguration" />
</bean>

<!-- <bean id="inferenceConfig" class="com.mywebsite.ws.im.InferenceService"> 
    <constructor-arg ref="playerConfiguration"/> </bean> -->

<!-- ~~~~~~~ Application beans ~~~~~~~ -->
<bean id="playerConfiguration"
    class="com.mywebsite.ws.configuration.WebServiceConfiguration"
    init-method="init">
    <property name="playerConfigXml" value="/WEB-INF/config/webserviceconfiguration.xml" />
    <property name="executingPathResource" value="/WEB-INF" />
    <property name="developmentMode" value="true" />
</bean>

3 个答案:

答案 0 :(得分:1)

替换appcontext的第一部分,您可以在其中定义名称空间:

<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">

答案 1 :(得分:1)

我强烈建议使用Maven。您得到的错误是由于缺少库。在Maven中你应该有如下条目。

    <dependency>
        <groupId>org.springframework.ws</groupId>
        <artifactId>spring-ws-core</artifactId>
        <version>2.1.0.RELEASE</version>
    </dependency>

答案 2 :(得分:0)

我建议你查看类路径和服务器运行时路径,我想你可能在编译/运行时都有(spring-ws 1.5.x和spring-ws 2.x)版本的jar文件路径。如果不是这样的话,那就清理这个类和运行时路径,只添加spring-ws 2.x jar文件。

至于差异,当spring框架名称空间处理程序(WebServicesNamespaceHandler)遇到 spring context 文件中的 dynamic-wsdl 标记时,它将注册一个(DynamicWsdlBeanDefinitionParser)具有动态wsdl标记中指定的所有属性的bean。它与在spring上下文中注册(DefaultWsdl11Definition)bean基本相同。