我在离线方案中使用wsdl2java工具和maven的cxf-codegen-plugin。 我有一个jar Types.jar ,包括常见的XML Schemata,它们使用jaxb2-maven-plugin转换为java类。我使用OASIS xml目录来引用常见模式的本地副本,例如XMLDSIG-核心schema.xsd。到目前为止这是有效的。
我还有一个 WebService.jar ,它由一个wsdl和一个伴随的xsd组成,它从 Types.jar 中导入Schemata。
运行maven构建时,出现以下错误:
Loading FrontEnd jaxws ...
Loading DataBinding jaxb ...
wsdl2java -encoding UTF-8 -d C:\path\to\my\project\src\generated\java -b classpath:/xsd/Types.xjb -b classpath:/xsd/simpleBinding.schemalet -xjc-verbose -xjc-encoding -xjcUTF-8 -xjc-
catalog -xjcC:/path/to/my/catalog.cat -catalog C:/path/to/my/catalog.cat -p http://ws.myws.com/Test=com.myws.ws.test -verbose -wsdlLocation wsdl/MYWSDL.wsdl file:/C:/path/to/my/MYWSDL.wsdl
wsdl2java - Apache CXF 2.7.11
[DEBUG]
org.apache.cxf.tools.common.ToolException: org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create wsdl definition file:/C:/path/to/my/MYWSDL.wsdl
_SOAP.wsdl: WSDLException (at /wsdl:definitions/wsdl:types/schema/xs:schema/xs:schema/schema): faultCode=PARSER_ERROR: Problem parsing 'jar:file:/C:/Users/me/.m2/repository/path/to/my/types.jar!/xsd/xmldsig-core-schema.xsd'.: java.net.UnknownHostException: www.w3.org
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.maven_plugin.wsdl2java.WSDL2JavaMojo.generate(WSDL2JavaMojo.java:427)
at org.apache.cxf.maven_plugin.AbstractCodegenMoho.execute(AbstractCodegenMoho.java:311)
at org.apache.cxf.maven_plugin.wsdl2java.WSDL2JavaMojo.execute(WSDL2JavaMojo.java:524)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create wsdl definition file:/C:/path/to/my/MYWSDL.wsdl_SOAP.wsdl: WSDLException (at /w
sdl:definitions/wsdl:types/schema/xs:schema/xs:schema/schema): faultCode=PARSER_ERROR: Problem parsing 'jar:file:/C:/Users/me/.m2/repository/path/to/my/types.jar!/xsd/xmldsig-core-schema.xsd'.: java.net.UnknownHostException: www.w3.org
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:82)
at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build(JAXWSDefinitionBuilder.java:59)
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)
... 27 more
Caused by: javax.wsdl.WSDLException: WSDLException (at /wsdl:definitions/wsdl:types/schema/xs:schema/xs:schema/schema): faultCode=PARSER_ERROR: Problem parsing 'jar:file:/C:/Users/me/.m2/repository/path/to/my/types.jar!/xsd/xmldsig-core-schema.xsd'.: java.net.UnknownHostException: www.w3.org
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:864)
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)
... 33 more
Caused by: java.net.UnknownHostException: www.w3.org
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at java.net.Socket.connect(Socket.java:528)
at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:211)
at sun.net.www.http.HttpClient.New(HttpClient.java:308)
at sun.net.www.http.HttpClient.New(HttpClient.java:326)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:996)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:932)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:850)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1300)
at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown Source)
at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(WSDLReaderImpl.java:2188)
... 45 more
我的catalog.cat看起来像这样:
SYSTEM "http://www.w3.org/2001/xml.xsd" "classpath:/xsd/xml.xsd"
PUBLIC "http://www.w3.org/2001/XMLSchema" "classpath:/xsd/xml.xsd"
PUBLIC "-//W3C//DTD XMLSchema 200102//EN" "classpath:/xsd/XMLSchema.dtd"
SYSTEM "http://www.w3.org/2001/XMLSchema.dtd" "classpath:/xsd/XMLSchema.dtd"
我尝试了cxf 2.7.6和2.7.11,我尝试了XML目录格式,我甚至将所有引用的Schemata复制到 WebService.jar 而没有类路径:目录中的表达式,都具有相同的结果和错误消息。
目录信息似乎丢失了。
有什么想法吗?
答案 0 :(得分:0)
(是的,我已经迟到了两年,但是)我认为这是由CXF-1505引起的错误wsdl4j bug 34。
所以:那些catalog.cat条目可能没什么问题(虽然你也需要一个datatypes.dtd,从XMLSchema.dtd引用),但由于这些错误,它们最终会被忽略。
一种解决方法,即使相当肮脏,是修改您的xsd / xmldsig-core-schema.xsd资源,而不是引用&#34; http://www.w3.org/2001/XMLSchema.dtd&#34;它只是指&#34; XMLSchema.dtd&#34;在同一目录中(并在该目录中放入datatypes.dtd的副本)。