WebService Client Generation Error with JDK8

后端 未结 23 2439
既然无缘
既然无缘 2020-11-27 08:50

I need to consume a web service in my project. I use NetBeans so I right-clicked on my project and tried to add a new \"Web Service Client\". Last time I checked, this was t

相关标签:
23条回答
  • 2020-11-27 09:31

    Enabling Access to External Schema

    You need to enable the IDE and the GlassFish Server to access external schema to parse the WSDL file of the web service. To enable access you need to modify the configuration files of the IDE and the GlassFish Server. For more details, see the FAQ How to enable parsing of WSDL with an external schema? Configuring the IDE

    To generate a web service client in the IDE from a web service or WSDL file you need to modify the IDE configuration file (netbeans.conf) to add the following switch to netbeans_default_options.

    -J-Djavax.xml.accessExternalSchema=all
    

    For more about locating and modifying the netbeans.conf configuration file, see Netbeans Conf FAQ. Configuring the GlassFish Server

    If you are deploying to the GlassFish Server you need to modify the configuration file of the GlassFish Server (domain.xml) to enable the server to access external schemas to parse the wsdl file and generate the test client. To enable access to external schemas, open the GlassFish configuration file (GLASSFISH_INSTALL/glassfish/domains/domain1/config/domain.xml) and add the following JVM option element (in bold). You will need to restart the server for the change to take effect.

    </java-config>
      ...
      <jvm-options>-Djavax.xml.accessExternalSchema=all</jvm-options>
    </java-config>
    
    0 讨论(0)
  • 2020-11-27 09:33

    Not an actual answer but more as a reference.

    If you are using the jaxws Maven plugin and you get the same error message, add the mentioned property to the plugin configuration:

    ...
    <plugin>
      <groupId>org.jvnet.jax-ws-commons</groupId>
      <artifactId>jaxws-maven-plugin</artifactId>
      <version>2.3</version>
      <configuration>
        <!-- Needed with JAXP 1.5 -->
        <vmArgs>
            <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
        </vmArgs>
      </configuration>
    </plugin>
    
    0 讨论(0)
  • 2020-11-27 09:33

    For those using the ANT task wsimport, a way of passing the option as suggested by @CMFly and specified in the documentation is the following:

    <wsimport
       <!-- ... -->
       fork="true"
      >
      <jvmarg value="-Djavax.xml.accessExternalSchema=all"/>
    </wsimport>
    
    0 讨论(0)
  • 2020-11-27 09:37

    If you are getting this problem when converting wsdl to jave with the cxf-codegen-plugin, then you can solve it by configuring the plugin to fork and provide the additional "-Djavax.xml.accessExternalSchema=all" JVM option.

            <plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-codegen-plugin</artifactId>
                <version>${cxf.version}</version>
                <executions>
                    <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <fork>always</fork>
                            <additionalJvmArgs>
                                -Djavax.xml.accessExternalSchema=all
                            </additionalJvmArgs>
    
    0 讨论(0)
  • 2020-11-27 09:37

    This works on jdk1.8.0_65

    wsimport -J-Djavax.xml.accessExternalSchema=all -keep -verbose https://your webservice url?wsdl
    
    0 讨论(0)
  • 2020-11-27 09:40

    I used it with a regular maven project, and got it solved with this plugin dependency configuration for running the xjc plugin:

         <plugin>
            <!-- Needed to run the plugin xjc en Java 8 or superior -->
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>properties-maven-plugin</artifactId>
            <version>1.0-alpha-2</version>
            <executions>
                <execution>
                    <id>set-additional-system-properties</id>
                    <goals>
                        <goal>set-system-properties</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <properties>
                    <property>
                        <name>javax.xml.accessExternalSchema</name>
                        <value>all</value>
                    </property>
                    <property>
                        <name>javax.xml.accessExternalDTD</name>
                        <value>all</value>
                    </property>
                </properties>
            </configuration>
        </plugin>
    
    0 讨论(0)
提交回复
热议问题