WSDL 文件上的 JAX-WS 错误:“解析组件 's:schema' 时出错”
错误
我在 Java 项目中使用 wsimport 为三个 SOAP Web 服务生成源代码。前两个工作正常:我使用JAX-WS Maven插件来抓取WSDL文件并生成相应的Java源文件。
对于一个 Web 服务,此操作将失败;我收到以下错误:
[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 行中注明的行中的内容:
<s:element ref="s:schema" />
注意:wsdl 文件的根元素定义了 “s” 命名空间,如下所示:
xmlns:s="http://www.w3.org/2001/XMLSchema"
我尝试过什么
我已经完成了我的研究。看起来其他人也有类似的问题,从“只是不要使用”到“使用导入标签”,再到一些不可知的解决方案,这些解决方案显然是在旧的 java.net 论坛上(在它被删除之前,现代亚历山大Java知识库的纵火)。<s:element ref="s:schema" />
-
我尝试将以下 import 语句放在包含问题标记的元素内:.wsimport给了我一个新的错误:
<s:import namespace="http://www.w3.org/2001/XMLSchema" schemaLocation="http://www.w3.org/2001/XMLSchema.xsd" />
[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 <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 <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 <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 行、第 199-200 行相似)
<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。同样的问题。
- 这里有一个可能的解决方案 - 我正在尝试弄清楚如何使用JAX-WS Maven插件来实现它。任何提示?
结论
有什么想法吗?您需要进一步的信息吗?为了简洁起见,我省略了 pom.xml 和 Service.asmx.wsdl 文件,但如果它们中有更重要的信息,可以包含它们。
谢谢!
附录
这是另一个有同样问题的人,如果这对任何潜在的回答者有帮助的话。这是另一个类似的问题。我并不真正理解这篇文章,但它似乎暗示我必须手动解析SOAP XML!恐怖!