【问题标题】:FileNotFoundException when importing an xsd导入 xsd 时出现 FileNotFoundException
【发布时间】:2018-04-03 13:34:03
【问题描述】:

我正在尝试创建 DefaultWsdl11Definition 类型的 bean,但是当项目部署到 weblogic 环境时,架构文件位置没有得到解析。

豆子:

 <bean id="pServiceWsdl" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
    <property name="schemaCollection">
        <bean class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">
            <property name="inline" value="true"/>
            <property name="xsds">
                <list>
                    <value>classpath:/p.xsd</value>
                </list>
            </property>
        </bean>
    </property>
    <property name="targetNamespace" value="http://example.com/p/"/>
    <property name="portTypeName" value="pPortType"/>
    <property name="serviceName" value="pService"/>
    <property name="locationUri" value="/services"/>
</bean>

架构文件包含以下内容:

<?xml version="1.0" encoding="UTF-8"?>

<xsd:include schemaLocation="p1.xsd"/>
<xsd:include schemaLocation="p2.xsd"/>

<xsd:element name="pRequest">
    <xsd:complexType>
        <xsd:sequence>
            <xsd:element name="p" type="C:p"/>
        </xsd:sequence>
    </xsd:complexType>
</xsd:element>
<xsd:element name="pResponse">
    <xsd:complexType>
        <xsd:sequence>
            <xsd:element name="pEnvelope" type="C:pEnvelope"/>
        </xsd:sequence>
    </xsd:complexType>
</xsd:element>

我收到的错误如下:

Caused By: java.io.FileNotFoundException: d:\p1.xsd(系统找不到指定的文件)

【问题讨论】:

    标签: spring web-services xsd filenotfoundexception


    【解决方案1】:

    在这种情况下,您必须指定完整路径。

    <xsd:include schemaLocation="classpath:com/example/p/oh/incoming/wsdl/com/example/p/xsd/PCBatchEnvelope-1p6.xsd"/>
    

    您还需要使用 commons xmlschema 将所有 xsd 内联到单个。因此,要启用它,您需要在 maven 中添加以下依赖项。

    <dependency>
         <groupId>org.apache.ws.commons.schema</groupId>
         <artifactId>XmlSchema</artifactId>
         <version>1.4.7</version>
    </dependency>
    

    【讨论】:

    • 不幸的是,我仍然收到同样的错误。你有什么想法吗?
    • 理想情况下它应该可以解决您的问题。检查您的类路径是否指向正确的文件夹。
    • 由于某种原因,它一直在我的 weblogic 域文件夹中搜索文件。我尝试使用 DeafultURIResolver,但到目前为止没有运气。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-15
    • 1970-01-01
    • 1970-01-01
    • 2020-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多