wsdl2java 错误:生成 java 代码时“无法创建 wsdl 定义”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27125272/
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
wsdl2java error: "Fail to create wsdl definition" while generating java code
提问by 4ntoine
I'm trying to generate java service code with apache-cxf wsdl2java
tool for wsdl:
https://raw.githubusercontent.com/mpromonet/spring-onvif/master/src/main/resources/wsdl/remotediscovery.wsdl
我正在尝试使用 apache-cxfwsdl2java
工具为 wsdl生成 java 服务代码:https:
//raw.githubusercontent.com/mpromonet/spring-onvif/master/src/main/resources/wsdl/remotediscovery.wsdl
MBA-Anton:bin asmirnov$ ./wsdl2java "https://raw.githubusercontent.com/mpromonet/spring-onvif/master/src/main/resources/wsdl/remotediscovery.wsdl" 25.11.2014 16:16:49 org.apache.cxf.configuration.jsse.SSLUtils getDefaultKeyStoreManagers WARNING: Default key managers cannot be initialized: /Users/asmirnov/.keystore (No such file or directory) [Fatal Error] addressing:2:2: The markup in the document following the root element must be well-formed.
WSDLToJava Error: org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create wsdl definition https://raw.githubusercontent.com/mpromonet/spring-onvif/master/src/main/resources/wsdl/remotediscovery.wsdl: WSDLException (at /wsdl:definitions/wsdl:types/xs:schema/xs:schema): faultCode=PARSER_ERROR: Problem parsing 'http://schemas.xmlsoap.org/ws/2004/08/addressing'.: org.xml.sax.SAXParseException: The markup in the document following the root element must be well-formed.
MBA-Anton:bin asmirnov$ ./wsdl2java " https://raw.githubusercontent.com/mpromonet/spring-onvif/master/src/main/resources/wsdl/remotediscovery.wsdl" 25.11.2014 16:16:49 org .apache.cxf.configuration.jsse.SSLUtils getDefaultKeyStoreManagers 警告:无法初始化默认密钥管理器:/Users/asmirnov/.keystore(无此类文件或目录)[致命错误]寻址:2:2:以下文档中的标记根元素必须格式良好。
WSDLToJava 错误:org.apache.cxf.wsdl11.WSDLRuntimeException:无法创建 wsdl 定义 https://raw.githubusercontent.com/mpromonet/spring-onvif/master/src/main/resources/wsdl/remotediscovery.wsdl:WSDLException(在 /wsdl:definitions/wsdl:types/xs:schema/xs:schema):faultCode=PARSER_ERROR:解析“ http://schemas.xmlsoap.org/ws/2004/08/addressing”时出现问题。:org.xml。 sax.SAXParseException:文档中根元素后面的标记必须格式正确。
Why is it trying to create wsdl definition instead of generating java code? How can i fix it?
为什么要尝试创建 wsdl 定义而不是生成 java 代码?我该如何解决?
Verbose log:
详细日志:
MBA-Anton:bin asmirnov$ ./wsdl2java -V "https://raw.githubusercontent.com/mpromonet/spring-onvif/master/src/main/resources/wsdl/remotediscovery.wsdl" Loading FrontEnd jaxws ... Loading DataBinding jaxb ... wsdl2java -V https://raw.githubusercontent.com/mpromonet/spring-onvif/master/src/main/resources/wsdl/remotediscovery.wsdlwsdl2java - Apache CXF 2.7.13
25.11.2014 16:18:39 org.apache.cxf.configuration.jsse.SSLUtils getDefaultKeyStoreManagers WARNING: Default key managers cannot be initialized: /Users/asmirnov/.keystore (No such file or directory) [Fatal Error] addressing:2:2: The markup in the document following the root element must be well-formed.
WSDLToJava Error: org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create wsdl definition https://raw.githubusercontent.com/mpromonet/spring-onvif/master/src/main/resources/wsdl/remotediscovery.wsdl: WSDLException (at /wsdl:definitions/wsdl:types/xs:schema/xs:schema): faultCode=PARSER_ERROR: Problem parsing 'http://schemas.xmlsoap.org/ws/2004/08/addressing'.: org.xml.sax.SAXParseException: The markup in the document following the root element must be well-formed.
org.apache.cxf.tools.common.ToolException: org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create wsdl definition https://raw.githubusercontent.com/mpromonet/spring-onvif/master/src/main/resources/wsdl/remotediscovery.wsdl: WSDLException (at /wsdl:definitions/wsdl:types/xs:schema/xs:schema): faultCode=PARSER_ERROR: Problem parsing 'http://schemas.xmlsoap.org/ws/2004/08/addressing'.: org.xml.sax.SAXParseException: The markup in the document following the root element must be well-formed. at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:420) at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103) at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113) at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86) at org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:184) Caused by: org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create wsdl definition https://raw.githubusercontent.com/mpromonet/spring-onvif/master/src/main/resources/wsdl/remotediscovery.wsdl: WSDLException (at /wsdl:definitions/wsdl:types/xs:schema/xs:schema): faultCode=PARSER_ERROR: Problem parsing 'http://schemas.xmlsoap.org/ws/2004/08/addressing'.: org.xml.sax.SAXParseException: The markup in the document following the root element must be well-formed. at org.apache.cxf.wsdl11.WSDLDefinitionBuilder.parseWSDL(WSDLDefinitionBuilder.java:97) at org.apache.cxf.wsdl11.WSDLDefinitionBuilder.build(WSDLDefinitionBuilder.java:69) at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build(JAXWSDefinitionBuilder.java:83) at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build(JAXWSDefinitionBuilder.java:60) at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:198) at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:164) at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:412) ... 4 more Caused by: javax.wsdl.WSDLException: WSDLException (at /wsdl:definitions/wsdl:types/xs:schema/xs:schema): faultCode=PARSER_ERROR: Problem parsing 'http://schemas.xmlsoap.org/ws/2004/08/addressing'.: org.xml.sax.SAXParseException: The markup in the document following the root element must be well-formed. at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(WSDLReaderImpl.java:2198) at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema(WSDLReaderImpl.java:830) at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema(WSDLReaderImpl.java:864) at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema(WSDLReaderImpl.java:654) at com.ibm.wsdl.xml.WSDLReaderImpl.parseTypes(WSDLReaderImpl.java:610) at com.ibm.wsdl.xml.WSDLReaderImpl.parseDefinitions(WSDLReaderImpl.java:320) at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(WSDLReaderImpl.java:2352) at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(WSDLReaderImpl.java:2338) at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:261) at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:206) at org.apache.cxf.wsdl11.WSDLDefinitionBuilder.parseWSDL(WSDLDefinitionBuilder.java:78) ... 10 more Caused by: org.xml.sax.SAXParseException: The markup in the document following the root element must be well-formed. at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:247) at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:287) at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(WSDLReaderImpl.java:2188) ... 20 more
MBA-Anton:bin asmirnov$ ./wsdl2java -V " https://raw.githubusercontent.com/mpromonet/spring-onvif/master/src/main/resources/wsdl/remotediscovery.wsdl" 加载前端jaxws ...加载数据绑定 jaxb ... wsdl2java -V https://raw.githubusercontent.com/mpromonet/spring-onvif/master/src/main/resources/wsdl/remotediscovery.wsdlwsdl2java - Apache CXF 2.7.13
25.11.2014 16:18:39 org.apache.cxf.configuration.jsse.SSLUtils getDefaultKeyStoreManagers 警告:无法初始化默认密钥管理器:/Users/asmirnov/.keystore(没有这样的文件或目录)[致命错误]寻址:2 :2: 文档中根元素后面的标记必须格式正确。
WSDLToJava 错误:org.apache.cxf.wsdl11.WSDLRuntimeException:无法创建 wsdl 定义 https://raw.githubusercontent.com/mpromonet/spring-onvif/master/src/main/resources/wsdl/remotediscovery.wsdl:WSDLException(在 /wsdl:definitions/wsdl:types/xs:schema/xs:schema):faultCode=PARSER_ERROR:解析“ http://schemas.xmlsoap.org/ws/2004/08/addressing”时出现问题。:org.xml。 sax.SAXParseException:文档中根元素后面的标记必须格式正确。
org.apache.cxf.tools.common.ToolException: org.apache.cxf.wsdl11.WSDLRuntimeException: 无法创建 wsdl 定义 https://raw.githubusercontent.com/mpromonet/spring-onvif/master/src/main/resources /wsdl/remotediscovery.wsdl:WSDLException(在 /wsdl:definitions/wsdl:types/xs:schema/xs:schema):faultCode=PARSER_ERROR:解析问题' http://schemas.xmlsoap.org/ws/2004/08 /寻址'.: org.xml.sax.SAXParseException: 根元素后面的文档中的标记必须格式正确。在 org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:420) 在 org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103) 在 org.apache.cxf .tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113) 在 org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86) 在 org.apache.cxf.tools.wsdlto.WSDLToJava.main (WSDLToJava.java:184) 引起:org.apache.cxf.wsdl11.WSDLRuntimeException:无法创建 wsdl 定义 https://raw.githubusercontent.com/mpromonet/spring-onvif/master/src/main/resources/wsdl /远程发现.wsdl:WSDLException(在/wsdl:definitions/wsdl:types/xs:schema/xs:schema):faultCode=PARSER_ERROR:解析问题' http://schemas.xmlsoap.org/ws/2004/08/addressing'.: org.xml.sax.SAXParseException: 根元素后面的文档中的标记必须格式正确。在 org.apache.cxf.wsdl11.WSDLDefinitionBuilder.parseWSDL(WSDLDefinitionBuilder.java:97) 在 org.apache.cxf.wsdl11.WSDLDefinitionBuilder.build(WSDLDefinitionBuilder.java:69) 在 org.apache.cxf.tools.wsdlto. .jaxws.wsdl11.JAXWSDefinitionBuilder.build(JAXWSDefinitionBuilder.java:83) at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build(JAXWSDefinitionBuilder.java:60.cxforg) .wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:198) 在 org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:164) 在 org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:164) .java:412) ...还有 4 个原因:http://schemas.xmlsoap.org/ws/2004/08/addressing'.: org.xml.sax.SAXParseException: 根元素后面的文档中的标记必须格式正确。在 com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(WSDLReaderImpl.java:2198) 在 com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema(WSDLReaderImpl.java:830) 在 com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema (WSDLReaderImpl.java:864) 在 com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema(WSDLReaderImpl.java:654) 在 com.ibm.wsdl.xml.WSDLReaderImpl.parseTypes(WSDLReaderImpl.java:610) 在 com.ibm。 wsdl.xml.WSDLReaderImpl.parseDefinitions(WSDLReaderImpl.java:320) 在 com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(WSDLReaderImpl.java:2352) 在 com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(WSDLReaderImpl.java:2352) 2338) 在 org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:261) 在 org.apache.cxf.wsdl11。WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:206) at org.apache.cxf.wsdl11.WSDLDefinitionBuilder.parseWSDL(WSDLDefinitionBuilder.java:78) ... 10 多个引起:org.xml.sax.SAXParseException:文档中的标记跟在根元素之后必须是格式良好的。在 com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:247) 在 com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:287)在 com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(WSDLReaderImpl.java:2188) ... 20 更多
回答by lexicore
My guess is that this has to do with the following import in ws-discovery.xsd:
我的猜测是这与ws-discovery.xsd 中的以下导入有关:
<xs:import namespace="http://schemas.xmlsoap.org/ws/2004/08/addressing" schemaLocation="http://schemas.xmlsoap.org/ws/2004/08/addressing"/>
To my surprise, the link http://schemas.xmlsoap.org/ws/2004/08/addressingworks but it redirects (HTTP 301) to http://schemas.xmlsoap.org/ws/2004/08/addressing/first (mind the trailing /
).
令我惊讶的是,链接http://schemas.xmlsoap.org/ws/2004/08/addressing有效,但它重定向(HTTP 301)到http://schemas.xmlsoap.org/ws/2004/08/addressing/首先(注意尾随/
)。
I think wsdl2java
does not follow the redirect. You could monitor/sniff network connections to find out exactly.
我认为wsdl2java
不遵循重定向。您可以监视/嗅探网络连接以准确找出。
Anyway, how to solve it.
无论如何,如何解决它。
You can use a catalog filewith wsdl2java:
您可以将目录文件与 wsdl2java 一起使用:
Make a local copy of the remote schema and use a catalog file like this one:
制作远程模式的本地副本并使用如下目录文件:
SYSTEM "http://schemas.xmlsoap.org/ws/2004/08/addressing" "src/main/resources/addressing.xsd"
(addressing.xsd
is your local copy).
(addressing.xsd
是您的本地副本)。
回答by Kevin Huang
It's SSL issue when you access the wsdl file. You can download the wsdl file first, and then do generate the java codes by using wsdl2java.
当您访问 wsdl 文件时,这是 SSL 问题。您可以先下载wsdl文件,然后使用wsdl2java生成java代码。
回答by Dinal
Remove the stylesheet entry <?xml-stylesheet type="text/xsl" href="http://www.onvif.org/onvif/ver20/util/onvif-wsdl-viewer.xsl"?>
from wsdl and try regenerating again.
<?xml-stylesheet type="text/xsl" href="http://www.onvif.org/onvif/ver20/util/onvif-wsdl-viewer.xsl"?>
从 wsdl 中删除样式表条目并再次尝试重新生成。