使用Spring WS发布静态WSDL和相关的XSD模式 [英] Publishing Static WSDL and related XSD schemas using Spring WS

查看:70
本文介绍了使用Spring WS发布静态WSDL和相关的XSD模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个模块,其中有我的XSD模式,其中一个模式可以使用模式位置内的相对路径引用另一个模式:

I have one module where I have my XSD schemas, where one schema can reference an other using relative path within schema location:

<xs:import namespace="http://my.namespace.org" schemaLocation="../mypackage/my.xsd"/>

在这里,我还使用xjc从这些xsd模式中生成Jaxb bean.

Here I'm also using xjc to generate Jaxb beans from these xsd schemas.

现在我有了一个使用spring-ws(2.0.4)实现我的Web服务的模块.我想使用静态WSDL 并将其与xsd模式一起发布,其中模式位置将转换为URL,例如"http://myerver.url.com/my.xsd".

Now I have a module where is my web-service is implemetented, using spring-ws (2.0.4). And I want to use static WSDL and publish it with the xsd schemas, where the schema locations will be transformed to URL like 'http://myerver.url.com/my.xsd'.

问题是如何优雅地实现这一目标?

(或者将XSD组合为一个模式,然后将其组合为WSDL)

(Alternatively combine the XSDs into one schema and that to WSDL)

(从理论上讲,我可以使用脚本转换这些XSD,并将它们添加到资源(xsd和wsdl)到(弹簧调度程序)servlet中,但是在我看来,这不是很舒服)

(In theory I could transform these XSD using a script and add them to resources (xsd and wsdl) to a (spring dispatcher) servlet but it doesn't seems to me very comfortable)

推荐答案

Spring Web服务实际上可以优雅地做到这一点.您需要做的就是在bean定义xml文件中定义一个具有正确ID(将用作没有.xsd的xsd名称)的 SimpleXsdSchema bean,如下所示

Spring web service has a way to do it elegantly actually. All you need to do is to define a SimpleXsdSchema bean with the right id (which will be used as the xsd name without .xsd) in the bean definition xml file, something like below

<bean id="my" 
        class="org.springframework.xml.xsd.SimpleXsdSchema">
        <property 
            name="xsd" 
            value="/mypackage/my.xsd">
        </property>
</bean>

更多信息(包括示例)可以在以下链接中找到:在Spring Web中具有导入的XML架构的静态WSDL服务

More information (including an example) can be found at the following link: Static WSDL with imported XML Schema in Spring Web Service

这篇关于使用Spring WS发布静态WSDL和相关的XSD模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆