WSDL文件上的JAX-WS错误:“错误解析组件:schema”" [英] JAX-WS error on WSDL file: "Error resolving component 's:schema'"

查看:117
本文介绍了WSDL文件上的JAX-WS错误:“错误解析组件:schema”"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Java项目中使用wsimport来生成三个SOAP Web服务的源。前两个工作正常:我使用JAX-WS Maven插件来获取WSDL文件并生成相应的Java源文件。

I am using wsimport in a Java project to generate sources for three SOAP web services. The first two work fine: I use the JAX-WS Maven plugin to grab the WSDL file and generate corresponding Java source files.

一个Web服务失败;我收到以下错误:

This fails for one web service; I get the following error:

[jaxws:wsimport]
Processing: /home/me/NetBeansProjects/Admin/AdminWeb/src/wsdl/erp-app-devel.srv.mycompany.ca/EgTestReportEngine/Service.asmx.wsdl
jaxws:wsimport args: [-s, /home/me/NetBeansProjects/Admin/AdminWeb/target/generated-sources/jaxws-wsimport, -d, /home/me/NetBeansProjects/Admin/AdminWeb/target/classes, -verbose, -catalog, /home/me/NetBeansProjects/Admin/AdminWeb/src/jax-ws-catalog.xml, -wsdllocation, http://erp-app-devel.srv.mycompany.ca/EgTestReportEngine/Service.asmx?WSDL, -target, 2.0, -extension, -Xnocompile, /home/me/NetBeansProjects/Admin/AdminWeb/src/wsdl/erp-app-devel.srv.mycompany.ca/EgTestReportEngine/Service.asmx.wsdl]
parsing WSDL...


src-resolve.4.2: Error resolving component 's:schema'. It was detected that 's:schema' is in namespace 'http://www.w3.org/2001/XMLSchema', but components from this namespace are not referenceable from schema document 'file:/home/me/NetBeansProjects/Admin/AdminWeb/src/wsdl/erp-app-devel.srv.mycompany.ca/EgTestReportEngine/Service.asmx.wsdl#types?schema1'. If this is the incorrect namespace, perhaps the prefix of 's:schema' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'file:/home/me/NetBeansProjects/Admin/AdminWeb/src/wsdl/erp-app-devel.srv.mycompany.ca/EgTestReportEngine/Service.asmx.wsdl#types?schema1'.
  line 80 of file:/home/me/NetBeansProjects/Admin/AdminWeb/src/wsdl/erp-app-devel.srv.mycompany.ca/EgTestReportEngine/Service.asmx.wsdl#types?schema1

undefined element declaration 's:schema'
  line 80 of file:/home/me/NetBeansProjects/Admin/AdminWeb/src/wsdl/erp-app-devel.srv.mycompany.ca/EgTestReportEngine/Service.asmx.wsdl

undefined element declaration 's:schema'
  line 127 of file:/home/me/NetBeansProjects/Admin/AdminWeb/src/wsdl/erp-app-devel.srv.mycompany.ca/EgTestReportEngine/Service.asmx.wsdl

undefined element declaration 's:schema'
  line 142 of file:/home/me/NetBeansProjects/Admin/AdminWeb/src/wsdl/erp-app-devel.srv.mycompany.ca/EgTestReportEngine/Service.asmx.wsdl


此WSDL文件与工作的文件之间的区别是错误消息中第80,127和142行所示的行:

The difference between this WSDL file and the ones that work is what's at the lines noted in the error message, lines 80, 127, and 142:

<s:element ref="s:schema" />

注意:wsdl文件的根元素定义了s命名空间:

Note: the root element of the wsdl file defines the "s" namespace thus:

xmlns:s="http://www.w3.org/2001/XMLSchema" 


我做了我的研究。它看起来像其他人有类似的问题,解决方案来自只是不要使用< s:element ref =s:schema/> , 使用导入标签,显示在旧的java.net论坛上的一些不可知的解决方案(在它被删除之前,是现代亚历山大的Java知识库的纵火)。

I have done my research. It looks like other people have had similar problems, with solutions from "just don't use <s:element ref="s:schema" />", to "use an import tag", to some unknowable solution that was apparently on the old java.net forum (before it was taken down, an arson of the modern-day Alexandrian Library of Java knowledge).


  • 我尝试将以下import语句放在包含问题标记的元素内:< s:import namespace =http ://www.w3.org/2001/XMLSchemaschemaLocation =http://www.w3.org/2001/XMLSchema.xsd/> 。 wsimport给了我一个新的错误:

  • I have tried putting the following import statement just inside the element that contains the problem tags: <s:import namespace="http://www.w3.org/2001/XMLSchema" schemaLocation="http://www.w3.org/2001/XMLSchema.xsd" />. wsimport gives me a new error:

[jaxws:wsimport]
Processing: /home/me/NetBeansProjects/Admin/AdminWeb/src/wsdl/erp-app-devel.srv.mycompany.ca/EgTestReportEngine/Service.asmx.wsdl
jaxws:wsimport args: [-s, /home/me/NetBeansProjects/Admin/AdminWeb/target/generated-sources/jaxws-wsimport, -d, /home/me/NetBeansProjects/Admin/AdminWeb/target/classes, -verbose, -catalog, /home/me/NetBeansProjects/Admin/AdminWeb/src/jax-ws-catalog.xml, -wsdllocation, http://erp-app-devel.srv.mycompany.ca/EgTestReportEngine/Service.asmx?WSDL, -target, 2.0, -extension, -Xnocompile, /home/me/NetBeansProjects/Admin/AdminWeb/src/wsdl/erp-app-devel.srv.mycompany.ca/EgTestReportEngine/Service.asmx.wsdl]
parsing WSDL...


Element "{http://www.w3.org/2001/XMLSchema}annotation" shows up in more than one properties.
  line 248 of http://www.w3.org/2001/XMLSchema.xsd

The following location is relevant to the above error
  line 242 of http://www.w3.org/2001/XMLSchema.xsd

Property "Any" is already defined. Use &lt;jaxb:property> to resolve this conflict.
  line 108 of file:/home/me/NetBeansProjects/Admin/AdminWeb/src/wsdl/erp-app-devel.srv.mycompany.ca/EgTestReportEngine/Service.asmx.wsdl

The following location is relevant to the above error
  line 109 of file:/home/me/NetBeansProjects/Admin/AdminWeb/src/wsdl/erp-app-devel.srv.mycompany.ca/EgTestReportEngine/Service.asmx.wsdl

Property "Any" is already defined. Use &lt;jaxb:property> to resolve this conflict.
  line 184 of file:/home/me/NetBeansProjects/Admin/AdminWeb/src/wsdl/erp-app-devel.srv.mycompany.ca/EgTestReportEngine/Service.asmx.wsdl

The following location is relevant to the above error
  line 185 of file:/home/me/NetBeansProjects/Admin/AdminWeb/src/wsdl/erp-app-devel.srv.mycompany.ca/EgTestReportEngine/Service.asmx.wsdl

Property "Any" is already defined. Use &lt;jaxb:property> to resolve this conflict.
  line 199 of file:/home/me/NetBeansProjects/Admin/AdminWeb/src/wsdl/erp-app-devel.srv.mycompany.ca/EgTestReportEngine/Service.asmx.wsdl

The following location is relevant to the above error
  line 200 of file:/home/me/NetBeansProjects/Admin/AdminWeb/src/wsdl/erp-app-devel.srv.mycompany.ca/EgTestReportEngine/Service.asmx.wsdl

此错误中引用的第108行和第109行是:(第184-5,1991行) 200是类似的)

Lines 108 and 109 referenced in this error are: (lines 184-5, 199-200 are similar)

<s:any minOccurs="0" maxOccurs="unbounded" namespace="http://www.w3.org/2001/XMLSchema" processContents="lax" />
<s:any minOccurs="1" namespace="urn:schemas-microsoft-com:xml-diffgram-v1" processContents="lax" />


  • 我尝试将jaxws-maven-plugin从1.10升级到2.2。同样的问题。

  • I have tried upgrading jaxws-maven-plugin from 1.10 to 2.2. Same problem.


    任何想法?您需要的任何进一步信息?为简洁起见,我省略了pom.xml和Service.asmx.wsdl文件,但如果其中包含更多重要信息,则可以包含它们。

    Any ideas? Any further information you need? I've omitted the pom.xml and Service.asmx.wsdl files for brevity, but could include them if there's more important information in them.

    谢谢!

    这是另一个有同样问题的人,如果这对任何潜在的回答者有帮助的话。
    这是另一个类似的问题。
    我真的不明白这篇文章,但是它似乎意味着我必须手动解析SOAP XML!恐怖!

    Here's another person having the same problem, if this is helpful to any potential answerers. Here's yet another similar problem. I don't really understand this article, but it seems to imply that I have to parse the SOAP XML manually! Horror!

    推荐答案

    我通过改编 Vivek Pandey的方法到Maven,同时更新到jaxws-maven-plugin 2.2。我将在此重申它的后代:

    I solved this by adapting Vivek Pandey's method to Maven, while updating to the jaxws-maven-plugin 2.2. I'll reiterate it here for posterity:

    这个XJB自定义文件(见下文)在你的默认绑定文件目录中,并设置wsimport来绑定它和http://www.w3.org/2001/XMLSchema.xsd

    Put this XJB customization file (see below) in your default binding files directory, and set wsimport to bind it and http://www.w3.org/2001/XMLSchema.xsd .

    上述XML文件xsd.xjb的内容应该放在默认的绑定文件目录中,如下所示(功劳归Kohsuke所有) :

    The contents of the aforementioned XML file, xsd.xjb, that should go in your default binding files directory, is as follows (credit goes to Kohsuke):

    <?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>
    



    POM



    这是相关部分我的POM文件,其中包含更改:

    POM

    Here's the relevant part of my POM file, with changes noted:

    <plugin>
        <!-- CHANGE: updated groupId and version -->
        <groupId>org.jvnet.jax-ws-commons</groupId>
        <artifactId>jaxws-maven-plugin</artifactId>
        <version>2.2</version>
        <executions>
            <execution> 
                <goals>
                    <goal>wsimport</goal>
                </goals>
                <configuration>
                    <!-- CHANGE: added args tag to bind http://www.w3.org/2001/XMLSchema.xsd -->
                    <args>
                        <arg>-b</arg><arg>http://www.w3.org/2001/XMLSchema.xsd</arg>
                    </args>
                    <wsdlFiles>
                        <wsdlFile>erp-app-devel.srv.mycompany.ca/EgTestReportEngine/Service.asmx.wsdl</wsdlFile>
                    </wsdlFiles>
                    <wsdlLocation>http://erp-app-devel.srv.mycompany.ca/EgTestReportEngine/Service.asmx.wsdl</wsdlLocation>
                    <staleFile>${project.build.directory}/jaxws/stale/Service.asmx.stale</staleFile>
                    <!-- CHANGE: added bindingFiles tag to bind XJB customization, located at the default binding files directory, MyProject/src/jaxws/xsd.xjb . -->
                    <bindingFiles>
                        <bindingFile>xsd.xjb</bindingFile>
                    </bindingFiles>
                </configuration>
                <id>wsimport-generate-egtestreportengine</id>
                <phase>generate-sources</phase>
            </execution>
        </executions>
        <dependencies>
            <dependency>
                <groupId>javax.xml</groupId>
                <artifactId>webservices-api</artifactId>
                <version>1.4</version>
            </dependency>
        </dependencies>
        <configuration>
            <sourceDestDir>${project.build.directory}/generated-sources/jaxws-wsimport</sourceDestDir>
            <xnocompile>true</xnocompile>
            <verbose>true</verbose>
            <extension>true</extension>
            <catalog>${basedir}/src/jax-ws-catalog.xml</catalog>
            <target>2.0</target>
        </configuration>
    </plugin>
    

    这篇关于WSDL文件上的JAX-WS错误:“错误解析组件:schema”&quot;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆