gpt4 book ai didi

java - 通过网络公开 jar 资源

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:58:33 24 4
gpt4 key购买 nike

我有一个网络服务(使用 Spring-WS)。

我有一个包含多个模式(schema1.xsd、schema2.xsd 和 schema3.xsd)的 jar,我将它们包含在我的 Web 服务中。

有没有办法在我的网络服务 wep 应用程序中通过 servlet 公开 jar 中的模式?

我的 Spring MessageDispatcherServlet 映射到/ws/

我希望我的模式公开给 /schemas/schema1.xsd /schemas/schema2.xsd 等等。

我知道如何使用 servlet 来完成它,但它太冗长了,必须有更好的方法。

我的想法是有一个 servlet 过滤器,所有命中/schemas/的东西都检查它是否在我的允许资源列表中并显示它。

这必须是与服务器无关的解决方案。 (例如 http://tuckey.org/urlrewrite/ 将不起作用)。

谢谢。

最佳答案

又是我!看到对您的原始问题的评论后,我想我会提供一个替代解决方案。

如果我理解您的问题,您似乎有一个 WSDL(由 Spring-WS 生成),其中包含对各种模式的引用。当客户端尝试遵循这些模式引用时,它会失败,因为没有这样的资源。

Spring-WS 提供了一个很好的方法来解决这个问题,这在 section on WSDL exposure 中有描述。 :

If you want to use multiple schemas, either by includes or imports, you might want to use the CommonsXsdSchemaCollection, and refer to that from the DefaultWsdl11Definition, like so:

<bean id="schemaCollection" class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">
<property name="xsds">
<list>
<value>classpath:/path/to/schema1.xsd</value>
<value>classpath:/path/to/schema2.xsd</value>
</list>
</property>
<property name="inline" value="true"/>
</bean>

When the inline property is enabled, it follows all XSD imports and includes, and inlines them in the WSDL. This greatly simplifies the deloyment of the schemas, which still making it possible to edit them separately.

因此,您得到的是一个生成的 WSDL,其中包含所有内联的引用模式,因此没有供客户端遵循的引用。它非常灵活,意味着您不必单独公开您的架构文件。

关于java - 通过网络公开 jar 资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2587526/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com