undefined element declaration 'xs:schema'

别说谁变了你拦得住时间么 提交于 2019-11-29 00:15:37

The solution to this appears to be supply alternate bindings for xs:schema as described in https://metro.java.net/2.1/guide/Dealing_with_schemas_that_are_not_referenced.html

Specifically, for the http://www.w3.org/2001/XMLSchema which is often imported into the namespace xs, there is some additional work that needs to be done.

The command would be: wsimport -b http://www.w3.org/2001/XMLSchema.xsd -b customization.xjb something.wsdl

customization.xjb linked from the above is at https://www.java.net//blog/kohsuke/archive/20070228/xsd.xjb or copied from below

This customization exists to handle some naming conflicts that might arise from using the schema Schema (which is imported as the same name space in multiple schemas).

customization.xjb

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

  <globalBindings>
    <xjc:simple />
  </globalBindings>

  <bindings scd="~xsd:complexType">
    <class name="ComplexTypeType"/>
  </bindings>

  <bindings scd="~xsd:simpleType">
    <class name="SimpleTypeType"/>
  </bindings>

  <bindings scd="~xsd:group">
    <class name="GroupType"/>
  </bindings>

  <bindings scd="~xsd:attributeGroup">
    <class name="AttributeGroupType"/>
  </bindings>

  <bindings scd="~xsd:element">
    <class name="ElementType"/>
  </bindings>

  <bindings scd="~xsd:attribute">
    <class name="attributeType"/>
  </bindings>
</bindings>

I have tried this with these files and the associated -b parameters to wsimport and have gotten (apparently) past this error (and on to other ones). That said, I'm not 100% certain that my new errors are not in part caused by this (and thus this wouldn't be a complete answer). Without the actual wsdl causing the problem, one can only take a reasonable guess as to solving the problem (and on to the next one).

I was facing same issue, resolved by just adding one line into maven plugin

  <args> <arg>-b</arg><arg>http://www.w3.org/2001/XMLSchema.xsd</arg>
  </args>

My maven plugin is given below

            <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxws-maven-plugin</artifactId>
            <version>2.4.1</version>
            <executions>
                <execution>
                    <id>periodictableaccessws</id>
                    <goals>
                        <goal>wsimport</goal>
                    </goals>
                    <configuration>
                        <wsdlDirectory>${basedir}/src/main/resources/wsdl</wsdlDirectory>
                        <args>
                            <arg>-b</arg><arg>http://www.w3.org/2001/XMLSchema.xsd</arg>
                        </args>
                        <wsdlFiles>
                            <wsdlFile>doosdaas.wsdl</wsdlFile>
                        </wsdlFiles>
                        <packageName>com.dss.doosdaas</packageName>
                        <vmArgs>
                            <vmArg>-Djavax.xml.accessExternalDTD=all</vmArg>
                            <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
                        </vmArgs>
                     <!--   <bindingDirectory>${basedir}/src/main/resources/jaxb</bindingDirectory>
                        <bindingFiles>
                            <bindingFile>jaxb_binding.xjb</bindingFile>
                        </bindingFiles>-->
                    </configuration>
                </execution>
            </executions>
        </plugin>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!