繁体   English   中英

Spring Configuration Web服务:从wsdl获取XsdSchema

[英]Spring Configuration web-services: get XsdSchema from wsdl

我有Spring Web服务配置。

public class WSConfig extends WsConfigurerAdapter {
    @Bean
        public XsdSchema getSchema() {
            return new SimpleXsdSchema(new ClassPathResource("wsdl/types/ewstypes.xsd"));
        }
...

如何从wsdl获取xsd? 因为我需要wsdl中的元素,所以无法更改此文件(例如,从中创建新的xsd并在@bean中返回)。

...
<wsdl:types>
            <xsd:schema xmlns:jxb="http://java.sun.com/xml/ns/jaxb" jxb:version="2.0"
                        elementFormDefault="qualified"
                        targetNamespace="http://foo/equeue/ws/"
                    >

                <xsd:import namespace="http://foo/equeue/ws/types/" schemaLocation="../types/etypes.xsd"/>
                <xsd:import namespace="http://bar/123"  schemaLocation="../types/ewstypes.xsd" />

                <xsd:element name="getRequest" type="smev:GetRequestType"/>
...

您可以做的一件简单的事情就是复制标签

<xsd:schema>

从您的WSDL及其所有内容到文件“ ewstypes.xsd”,这将产生一个完全有效的XSD模式。

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:jxb="http://java.sun.com/xml/ns/jaxb" jxb:version="2.0"
                        elementFormDefault="qualified"
                        targetNamespace="http://foo/equeue/ws/"
                    >

                <xsd:import namespace="http://foo/equeue/ws/types/" schemaLocation="../types/etypes.xsd"/>
                <xsd:import namespace="http://bar/123"  schemaLocation="../types/ewstypes.xsd" />

                <xsd:element name="getRequest" type="smev:GetRequestType"/>
....
</xsd:schema>

然后像现在一样将其公开为Bean。 希望这可以帮助!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM