xsd:include exception in soapUI:org.apache.xmlbeans.xmllexce



在soapUI中创建新项目并从URL导入wsdl文件时遇到问题。它给了我下面的异常

加载错误[http://localhost:8080/WS/PersonalDetails。xsd]: org.apache.xmlbeans.XmlException: error: file end after null

我的xsd包含

<xsd:include schemaLocation="PersonalDetails.xsd" />
<xsd:include schemaLocation="PersonalRequest.xsd" />

xsd的实际位置

WS/src/main/webapp/schemas/PersonalDetails.xsd
WS/src/main/webapp/schemas/PersonalRequest.xsd
我spring-ws.xml

<bean id="MyWSService" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition" lazy-init="true">
    <property name="schemaCollection">
        <bean class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">
            <property name="inline" value="false" />
            <property name="xsds">
                <list>
                    <value>schemas/PersonalDetailsServiceOperations.xsd</value>
                </list>
            </property>
        </bean>
    </property>
    <property name="portTypeName" value="MyWSEndpoint"/>
    <property name="serviceName" value="MyWS" />
    <property name="locationUri" value="/"/>
</bean>
我PersonalDetailsServiceOperations.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:person="http://MyWS.com/"
targetNamespace="http://MyWS.com/"
elementFormDefault="qualified">
<xsd:include schemaLocation="PersonalDetails.xsd" />
<xsd:include schemaLocation="PersonalRequest.xsd" />
</xsd:schema>

我正在使用spring+Maven+xsd+jaxb

请帮

多谢

通常发生这种情况是因为您没有将WSDL的正确位置粘贴到SOAP UI中。当您在浏览器中浏览WSDL时,spring-ws将在几乎任何url上提供它,只要它以XYZService结尾。WSDL(或您配置为的任何格式)。这样做的缺点是,当您使用模式内的相对路径导入XSD时,SOAP UI会尝试根据您提供的路径来解析相对路径,但就像我说的,这可能实际上不是WSDL的真正路径。

例如,在我们的应用程序中,我们有一个Spring-ws web服务调用ProcessService。它在http://localhost:11000/ws/service/process/ProcessService.wsdl上提供,它包含一个使用相对路径导入的XSD。如果将此URL粘贴到SOAP UI中并运行它,它将正确地将路径解析为XSD。但是,您可以浏览到http://localhost:11000/hello-world/ProcessService.wsdl,即使URL不正确,它仍然会为您提供WSDL。现在,如果您将http://localhost:11000/hello-world/ProcessService.wsdl粘贴到SOAP UI中,它将无法正确解析导入XSD的相对路径,因为这不是实际的URL。在这种情况下,SOAP UI给出了确切的错误。

我将在浏览器中浏览到您的XSD,并确保您可以看到它。然后我会检查您粘贴到SOAP UI中的URL,并查看相对URL是否正确解析。如果没有,则需要为SOAP UI提供正确的路径。

最新更新