如何在spring Web服务中发布wsdl时处理xsds的相对路径?

时间:2015-04-29 14:40:15

标签: web-services soap xsd wsdl

我有通过Springs公开的Soap Web服务... 我需要公开WSDL。用于公开WSDL的My Bean定义如下所示。

<bean id="schemaCollection" class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">
<description>
This bean wrap the messages.xsd (which imports types.xsd), and inlines them as a one.
</description>
<property name="xsds">
<list>
<value>/WEB-INF/classes/schema/HL7V3/NE2008/multicacheschemas/PRPA_IN201301UV02.xsd</value>
<value>/WEB-INF/classes/schema/HL7V3/NE2008/multicacheschemas/PRPA_IN201302UV02.xsd</value>
<value>/WEB-INF/classes/schema/HL7V3/NE2008/multicacheschemas/PRPA_IN201304UV02.xsd</value>
<value>/WEB-INF/classes/schema/HL7V3/NE2008/multicacheschemas/MCCI_IN000002UV01.xsd</value>
<value>/WEB-INF/classes/schema/HL7V3/NE2008/multicacheschemas/PRPA_IN201309UV02.xsd</value>
<value>/WEB-INF/classes/schema/HL7V3/NE2008/multicacheschemas/PRPA_IN201310UV02.xsd</value>
</list>
</property>
<property name="inline" value="true"/>
</bean>

<bean id="pixManager" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
<property name="schemaCollection" ref ="schemaCollection"/>
<property name="portTypeName" value="PIXManager_PortType"/>
<property name="locationUri" value="/services/pixManager/"/>
</bean>

我在这里遇到的问题是我有从这些XSD引用的子XSD,如下所示,但没有得到解决。

<xs:include schemaLocation="../coreschemas/infrastructureRoot.xsd"/>

我收到以下错误..

Caused by: org.springframework.xml.xsd.commons.CommonsXsdSchemaException: Schema [ServletContext resource [/WEB-INF/classes/schema/HL7V3/NE2008/multicaches
chemas/PRPA_IN201301UV02.xsd]] could not be loaded; nested exception is java.lang.IllegalArgumentException: The resource path [/../coreschemas/infrastructu
reRoot.xsd] has been normalized to [null] which is not valid

其中[/../coreschemas/infrastructu     reRoot.xsd]是子XSD的相对路径。

1 个答案:

答案 0 :(得分:1)

您只需要提取交互所需的模式,因此文件夹结构将如下所示:

../coreschemas
../schemas

然后将交互模式和相关模式“扁平化”为一个可以嵌入到WSDL中的模式。