java - cxf:cxf-codegen-plugin:2.1.2:wsdl2java 失败:索引 2 处不透明部分中的非法字符

标签 java web-services cxf wsdl2java

由于以下异常,我无法使用 cxf:cxf-codegen-plugin 从 WSDL 生成所需的源:

[ERROR] Failed to execute goal org.apache.cxf:cxf-codegen-plugin:2.1.2:wsdl2java (generate-sources) on project innoclient: Execution generate-sources of goal org.apache.cxf:cxf-codegen-plugin:2.1.2:wsdl2java failed: Illegal character in opaque part at index 2: C:\WORK\BAG\WS\POC\innoclient/src/main/wsdl/mywsdl.wsdl -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.cxf:cxf-codegen-plugin:2.1.2:wsdl2java (generate-sources) on project innoclient: Execution generate-sources of goal org.apache.cxf:cxf-codegen-plugin:2.1.2:wsdl2java failed: Illegal character in opaque part at index 2: C:\WORK\WS\POC\src/main/wsdl/mywsdl.wsdl
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)
        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:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
        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:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution generate-sources of goal org.apache.cxf:cxf-codegen-plugin:2.1.2:wsdl2java failed: Illegal character in opaque part at index 2: C:\WORK\WS\POC\src/main/wsdl/mywsdl.wsdl
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:143)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        ... 19 more
Caused by: java.lang.IllegalArgumentException: Illegal character in opaque part at index 2: C:\WORK\WS\POC\src/main/wsdl/mywsdl.wsdl
        at java.net.URI.create(URI.java:859)
        at java.net.URI.resolve(URI.java:1043)
        at org.apache.cxf.maven_plugin.WSDL2JavaMojo.processWsdl(WSDL2JavaMojo.java:278)
        at org.apache.cxf.maven_plugin.WSDL2JavaMojo.execute(WSDL2JavaMojo.java:228)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
        ... 20 more
Caused by: java.net.URISyntaxException: Illegal character in opaque part at index 2: C:\WORK\WS\POC\src/main/wsdl/mywsdl.wsdl
        at java.net.URI$Parser.fail(URI.java:2829)
        at java.net.URI$Parser.checkChars(URI.java:3002)
        at java.net.URI$Parser.parse(URI.java:3039)
        at java.net.URI.<init>(URI.java:595)
        at java.net.URI.create(URI.java:857)
        ... 24 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

我的 WSDL 的定义部分如下所示:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://AcmeToolKit.com/"
    xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
    xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://AcmeToolKit.com/"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
    <wsdl:types>
        <s:schema elementFormDefault="qualified"

任何解决此问题的指针都会有所帮助。

感谢致敬,

最佳答案

问题似乎出在路径本身。
"C:\WORK\WS\POC\src/main/wsdl/mywsdl.wsdl"不是有效的 IRI - 即异常是关于,而不是文件本身的内容。

如果你有类似的东西

<bindingFile>${basedir}/src/main/resources/binding.xml</bindingFile>

在您的 pom.xml 文件中,只需将其更改为:
<bindingFile>./src/main/resources/binding.xml</bindingFile>

可能不是最好的,但可以完成工作。

关于java - cxf:cxf-codegen-plugin:2.1.2:wsdl2java 失败:索引 2 处不透明部分中的非法字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36896612/

相关文章:

java - 如何在多节点生产服务器上迁移数据库?

java - 在 Java 中使用 ScheduledExecutorService 定期运行任务

java - 将 Servlet 上下文参数传递给 Spring MVC Controller

c# - 用 .net2.0 和 .net4.0 编写的 Web 服务客户端之间的区别

c# - 如何在一个 catch block 中捕获所有类型的异常?

java - 带有请求消息的 Apache CXF ExceptionMapper

java - 在 GET 请求中将 java.util.Set 作为 QueryParam 值传递

java - 如何在java(Excel)中写入特定列并读取特定列?

java - Apache CXF 未释放客户端

java - 从 JAX-WS 生成的代码访问 Web 服务时如何指定主机和端口?