Is there a way to expose a static XSD in Spring WS

2019-05-18 22:42发布

问题:

If, for example orders.wsdl imports Orders.xsd, how can it be configured using static-wsdl

<sws:static-wsdl id="orders" location="/WEB-INF/wsdl/orders.wsdl"/>

such that Orders.xsd can be viewed in the browser like http://host/context/Orders.xsd

Dynamic wsdl supports it.

<sws:dynamic-wsdl id="orders"
    portTypeName="Orders"
    locationUri="http://localhost:8080/ordersService/">
  <sws:xsd location="/WEB-INF/xsd/Orders.xsd"/>
</sws:dynamic-wsdl>

But static-wsdl doesn't have the sws:xsd property.

回答1:

There is no namspace support but you can do this -

<bean id="Orders" class="org.springframework.xml.xsd.SimpleXsdSchema">
    <property name="xsd" value="classpath:/Orders.xsd" />
</bean>

This will resolve the referenced xsd in your wsdl file -

<wsdl:types>
    <xsd:schema elementFormDefault="qualified">
        <xsd:import namespace="..." schemaLocation="Orders.xsd"></xsd:import>
    </xsd:schema>
</wsdl:types>


回答2:

or you can tyt with that

 <wsdl:types>


   <xs:schema targetNamespace="...."
          elementFormDefault="qualified">

                <xs:include schemaLocation="xsd/Order.xsd"/>

   </xs:schema>