从WSDL生成Java类时出现SAXParseException2

时间:2018-11-19 09:39:36

标签: java jaxb wsdl

如何使 maven-jaxb2-plugin 成功地从given wsdl生成Java类?

pom:

<plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <version>0.14.0</version>
    <executions>
        <execution>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <args>
            <arg>-XautoNameResolution</arg>
        </args>
        <!--<generatePackage>com.example.demo.schema.gbg</generatePackage>-->
        <generateDirectory>${project.basedir}/src/main/java</generateDirectory>
        <schemaDirectory>${project.basedir}/src/main/resources/wsdl</schemaDirectory>
        <schemaIncludes>
            <include>*.wsdl</include>
        </schemaIncludes>
        <bindingDirectory>${project.basedir}/src/main/resources/bindings/</bindingDirectory>
        <bindingIncludes>*.xml</bindingIncludes>
    </configuration>
</plugin>

控制台:

[ERROR] Error while generating code.Location [ https://pilot.id3global.com/ID3gWS/ID3global.svc?xsd=xsd0{1,156554}].
com.sun.istack.SAXParseException2; systemId: https://pilot.id3global.com/ID3gWS/ID3global.svc?xsd=xsd0; lineNumber: 1; columnNumber: 156554; (Related to above error) This is the other declaration.  
sample java project复制的

jaxb-bindings.xml

<?xml version="1.0" encoding="UTF-8" ?>
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
               xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.1">
    <jaxws:bindings
            xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
            xmlns:xs="http://www.w3.org/2001/XMLSchema">

        <!-- Name the package consistently (don't use wsdl URI domain name) -->
        <jaxws:package name="com.id3global"/>
        <!-- Use 'wrapper style rules' to produce Java names - no I don't know what it means either -->
        <jaxws:enableWrapperStyle>true</jaxws:enableWrapperStyle>
        <!-- Disable generation of asynchronous send/receive methods - might be fun for later though :) -->
        <jaxws:enableAsyncMapping>false</jaxws:enableAsyncMapping>

        <!-- Do not generate Element properties - they collide with the type namespace in Java,
            and yes, *all* this boilerplate is required for wsimport to apply the setting correctly -->
        <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
                   xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" elementFormDefault="qualified"
                   xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
                   attributeFormDefault="unqualified" jaxb:extensionBindingPrefixes="xjc" jaxb:version="2.1">
            <xs:annotation>
                <xs:appinfo>
                    <jaxb:globalBindings generateElementProperty="false">
                        <xjc:serializable/>
                    </jaxb:globalBindings>
                </xs:appinfo>
            </xs:annotation>
        </xs:schema>
    </jaxws:bindings>
</jaxb:bindings>

我不确定如何整合以及是否有帮助的摘要:

<jaxb:schemaBindings>
                <jaxb:nameXmlTransform>
                    <jaxb:typeName suffix="Element"/>
                    <jaxb:elementName suffix="Type"/>
                </jaxb:nameXmlTransform>
            </jaxb:schemaBindings>

0 个答案:

没有答案