java xsd:在soapUI 中包含异常:org.apache.xmlbeans.XmlException:org.apache.xmlbeans.XmlException:错误:null 后出现意外的文件结尾
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31779004/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
xsd:include exception in soapUI:org.apache.xmlbeans.XmlException: org.apache.xmlbeans.XmlException: error: Unexpected end of file after null
提问by senthil raja
I have a problem while creating new project in soapUI and importing wsdl file from URL.It gives me the below exception
我在soapUI中创建新项目并从URL导入wsdl文件时遇到问题。它给了我以下异常
Error loading [http://localhost:8080/WS/PersonalDetails.xsd]: org.apache.xmlbeans.XmlException: org.apache.xmlbeans.XmlException: error: Unexpected end of file after null
加载 [ http://localhost:8080/WS/PersonalDetails.xsd] 时出错:org.apache.xmlbeans.XmlException:org.apache.xmlbeans.XmlException:错误:null 后出现意外的文件结尾
My xsd include
我的 xsd 包括
<xsd:include schemaLocation="PersonalDetails.xsd" />
<xsd:include schemaLocation="PersonalRequest.xsd" />
Actual Location of the xsd
xsd 的实际位置
WS/src/main/webapp/schemas/PersonalDetails.xsd
WS/src/main/webapp/schemas/PersonalRequest.xsd
My spring-ws.xml
我的 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>
My PersonalDetailsServiceOperations.xsd
我的 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>
I'm using spring+Maven+xsd+jaxb
我正在使用 spring+Maven+xsd+jaxb
Please help
请帮忙
Many Thanks
非常感谢
回答by James Tayler
Often this happens because you're not pasting in the correct location to the WSDL into SOAP UI. When you browse to your WSDL in a browser, spring-ws will serve it up on almost any url, so long as it ends in XYZService.wsdl (or whatever you have configured it to be). The downside to this is, when you have XSD imported using relative paths inside your schema somewhere, SOAP UI tries to to resolve the relative path based on the path you gave it, but like I said, that may not actually be the real path to the WSDL.
通常发生这种情况是因为您没有将 WSDL 的正确位置粘贴到 SOAP UI 中。当您在浏览器中浏览到您的 WSDL 时,spring-ws 将在几乎任何 url 上提供它,只要它以 XYZService.wsdl 结尾(或您配置的任何内容)。这样做的缺点是,当您使用架构内某处的相对路径导入 XSD 时,SOAP UI 会尝试根据您提供的路径解析相对路径,但就像我说的,这实际上可能不是真正的路径WSDL。
For example, in our application we have a Spring-ws web service call ProcessService. It's served up at http://localhost:11000/ws/service/process/ProcessService.wsdland it contains an imported XSD using relative paths. If you paste this URL into SOAP UI and run it, it correctly resolves the path to XSD. However, you can browse to http://localhost:11000/hello-world/ProcessService.wsdland it will still serve you up the WSDL even though the URL is not correct. Now if you take http://localhost:11000/hello-world/ProcessService.wsdland paste it into SOAP UI it won't be able to resolve the relative path to imported XSD correctly because that's not the actual URL. In this case SOAP UI gives you that exact error.
例如,在我们的应用程序中,我们有一个 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 会给出确切的错误。
I would browse to your XSD in the browser and make sure you can see it. Then I would check the URL you are pasting into SOAP UI and see if from the relative URLs actually resolve correctly. If not, you need to give the correct path to SOAP UI.
我会在浏览器中浏览到您的 XSD 并确保您可以看到它。然后我会检查您粘贴到 SOAP UI 中的 URL,并查看相对 URL 是否确实正确解析。如果没有,您需要提供 SOAP UI 的正确路径。