Spring-WS:带有 WSDL 多节点分类的 SimpleWsdl11Definition

发布于 2024-09-13 05:40:00 字数 795 浏览 5 评论 0原文

Spring-WS 1.5:使用 SimpleWsdl11Definition,在 XML 配置中公开 WSDL 非常简单(来自 Spring-WS 文档):

<bean id="orders" class="org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition">
    <constructor-arg value="/WEB-INF/wsdl/Orders.wsdl"/>
</bean>

生成一个公开 WSDL 的 URL:

http://localhost:8080/spring-ws/orders.wsdl

SimpleWsdl11Definition bean id +“.wsdl”在部署时成为 WSDL URL 的叶子,它涵盖了单节点分类法。

我需要支持具有多节点分类法的 WSDL 的公开。

例如:

http://localhost:8080/spring-ws/domain/subdomain/foo.wsdl

在 Spring-WS 中这是如何实现的? Bean ID 属性不允许使用“/”字符,因此我想知道有什么方法可以影响 WSDL URL。

注意:不能选择使用生成的 WSDL(出于向后一致性的原因),例如使用 DefaultWsdl11Definition。与 SimpleWsdl11Definition 一样,我想将对 WSDL 的请求映射到静态 WSDL。

谢谢。

Spring-WS 1.5: Using SimpleWsdl11Definition, exposing a WSDL is straightforward (from Spring-WS doc) in XML configuration:

<bean id="orders" class="org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition">
    <constructor-arg value="/WEB-INF/wsdl/Orders.wsdl"/>
</bean>

Yields a URL exposing the WSDL at:

http://localhost:8080/spring-ws/orders.wsdl

The SimpleWsdl11Definition bean id + ".wsdl" becomes the leaf of the WSDL's URL when deployed, which covers a single-node taxonomy.

I need to support exposure of WSDLs that have multi-node taxonomies.

For instance:

http://localhost:8080/spring-ws/domain/subdomain/foo.wsdl

How is this accomplished in Spring-WS? Bean ID attributes do not allow "/" characters, so I wonder what ways exist to influence the WSDL URL.

Note: Using generated WSDLs will not be on option (for backward-consistency reasons), for instance with DefaultWsdl11Definition. As with SimpleWsdl11Definition, I'd like to map requests for the WSDL to the static WSDL.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

伴梦长久 2024-09-20 05:40:00

我遇到了同样的问题,使用不同的 url 公开两个版本的 Web 服务。

old version within http://hostname/ws.wsdl
new version within http://hostname/version/ws.wsdl

我的解决方案不是使用通用的 org.springframework.ws.transport.http.MessageDispatcherServletservlet 而是使用默认的 org.springframework.web.servlet.DispatcherServlet 并在我的 bean 配置中配置 url 映射到不同的 wsdl 版本。

我更喜欢这个解决方案,因为它无需子类化任何 spring 类即可工作。

web.xml:

<servlet>
    <servlet-name>webservice</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value></param-value>
    </init-param>
</servlet>

<servlet-mapping>
    <servlet-name>webservice</servlet-name>
    <url-pattern>/ws</url-pattern>
    <url-pattern>/ws.wsdl</url-pattern>
    <url-pattern>/version/ws</url-pattern>
    <url-pattern>/version/ws.wsdl</url-pattern>
</servlet-mapping>

beans.xml

<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory" />

<bean
    class="org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter">
    <property name="messageFactory" ref="messageFactory" />
</bean>

<bean id="messageDispatcher"
    class="org.springframework.ws.soap.server.SoapMessageDispatcher" />

<bean
    class="org.springframework.ws.transport.http.WsdlDefinitionHandlerAdapter" />

<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    <property name="mappings">
        <props>
            <prop key="/ws.wsdl">ws</prop>
            <prop key="/version/ws.wsdl">ws-newversion</prop>
        </props>
    </property>
    <property name="defaultHandler" ref="messageDispatcher" />
</bean>

<bean id="ws"
    class="org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition">
    <constructor-arg value="classpath:wsdl/oldversion/Service.wsdl" />
</bean>

<bean id="ws-newversion"
    class="org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition">
    <constructor-arg value="classpath:wsdl/newversion/CarService.wsdl" />
</bean>

因此,每个 wsdl 都在 SimpleUrlHandlerMapping-Bean 中配置的给定路径中公开。

I got the same problem exposing two versions of a webservice with different urls.

old version within http://hostname/ws.wsdl
new version within http://hostname/version/ws.wsdl

My solution was not using the generic org.springframework.ws.transport.http.MessageDispatcherServletservlet but the default org.springframework.web.servlet.DispatcherServlet and configuring the url mappings to the different wsdl versions in my bean config.

I prefer this solution because it works without subclassing any spring classes.

web.xml:

<servlet>
    <servlet-name>webservice</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value></param-value>
    </init-param>
</servlet>

<servlet-mapping>
    <servlet-name>webservice</servlet-name>
    <url-pattern>/ws</url-pattern>
    <url-pattern>/ws.wsdl</url-pattern>
    <url-pattern>/version/ws</url-pattern>
    <url-pattern>/version/ws.wsdl</url-pattern>
</servlet-mapping>

beans.xml

<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory" />

<bean
    class="org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter">
    <property name="messageFactory" ref="messageFactory" />
</bean>

<bean id="messageDispatcher"
    class="org.springframework.ws.soap.server.SoapMessageDispatcher" />

<bean
    class="org.springframework.ws.transport.http.WsdlDefinitionHandlerAdapter" />

<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    <property name="mappings">
        <props>
            <prop key="/ws.wsdl">ws</prop>
            <prop key="/version/ws.wsdl">ws-newversion</prop>
        </props>
    </property>
    <property name="defaultHandler" ref="messageDispatcher" />
</bean>

<bean id="ws"
    class="org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition">
    <constructor-arg value="classpath:wsdl/oldversion/Service.wsdl" />
</bean>

<bean id="ws-newversion"
    class="org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition">
    <constructor-arg value="classpath:wsdl/newversion/CarService.wsdl" />
</bean>

Thus each wsdl is exposed at the given path configured in the SimpleUrlHandlerMapping-Bean.

北风几吹夏 2024-09-20 05:40:00

在研究了 spring-ws 源代码后,我发现不支持为静态源 WSDL 配置公开多节点路径。

因此,我对 MessageDispatcherServlet 和 SimpleWsdl11Definition 进行了子类化,并在我的 servlet 中提供了我自己的 WSDL 请求映射器,该映射器支持现有的 WsdlDefinition bean 以及我的“位置指定”WsdlDefinition bean。

产生以这种方式配置的能力:

<!-- exposes URL:  host/context-root/servlet-name/MyService.wsdl -->
<bean id="MyService" class="org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition">
    <property name="wsdl" value="/WEB-INF/wsdl/MyService.wsdl" />
</bean>

<!-- exposes URL:  host/context-root/servlet-name/some/multi/node/taxonomy/path/MyService.wsdl -->
<bean id="MyService.otherVersion" class="path.to.my.EnhancedWsdl11Definition">
    <property name="wsdl" value="/WEB-INF/wsdl/otherVersion/MyService.wsdl" />
    <property name="locationUri" value="some/multi/node/taxonomy/path/MyService.wsdl" />
</bean>

一切都很好。

After poking around spring-ws source, I found there is no support for exposing a multi-node path for static-sourced WSDL configuration.

So I subclassed MessageDispatcherServlet and SimpleWsdl11Definition, and in my servlet, provided my own WSDL-request mapper that supports existing WsdlDefinition beans, as well as my "location-specified" WsdlDefinition bean.

Yields ability to configure in this sort of manner:

<!-- exposes URL:  host/context-root/servlet-name/MyService.wsdl -->
<bean id="MyService" class="org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition">
    <property name="wsdl" value="/WEB-INF/wsdl/MyService.wsdl" />
</bean>

<!-- exposes URL:  host/context-root/servlet-name/some/multi/node/taxonomy/path/MyService.wsdl -->
<bean id="MyService.otherVersion" class="path.to.my.EnhancedWsdl11Definition">
    <property name="wsdl" value="/WEB-INF/wsdl/otherVersion/MyService.wsdl" />
    <property name="locationUri" value="some/multi/node/taxonomy/path/MyService.wsdl" />
</bean>

All is well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文