gpt4 book ai didi

java - 使用 WSDL2Java 从 WSDL 生成的源使用 java 11 上已弃用的 API javax xml ws 生成类

转载 作者:太空宇宙 更新时间:2023-11-04 09:20:54 24 4
gpt4 key购买 nike

在我的项目中,我使用的是 java 11。

基于 WSDL 文件,我使用 cxf-codegen-plugin maven 插件生成代码类。生成的类,使用 javax.xml.ws.* 和 java 11 上的其他 API。

示例:

生成的类之一 extends Service 来自 javax.xml.ws.Service 该库在 java 11 上并未弃用,但我遇到了兼容性错误。

java.lang.IllegalArgumentException: JAXP09020005: The specified argument 'classpath:/schemas/wsdl' (case sensitive) for 'setRewritePrefix' is not valid.
at java.xml/javax.xml.catalog.CatalogMessages.reportIAE(CatalogMessages.java:140) ~[na:na]
at java.xml/javax.xml.catalog.BaseEntry.verifyURI(BaseEntry.java:231) ~[na:na]
at java.xml/javax.xml.catalog.RewriteSystem.setRewritePrefix(RewriteSystem.java:65) ~[na:na]
at java.xml/javax.xml.catalog.RewriteSystem.<init>(RewriteSystem.java:47) ~[na:na]
at java.xml/javax.xml.catalog.CatalogReader.startElement(CatalogReader.java:190) ~[na:na]
at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:510) ~[na:na]
at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:183) ~[na:na]
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:351) ~[na:na]
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2708) ~[na:na]
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605) ~[na:na]
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112) ~[na:na]
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:534) ~[na:na]
at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:888) ~[na:na]
at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:824) ~[na:na]
at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) ~[na:na]
at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1216) ~[na:na]
at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:635) ~[na:na]
at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:324) ~[na:na]
at java.xml/javax.xml.parsers.SAXParser.parse(SAXParser.java:276) ~[na:na]
at java.xml/javax.xml.catalog.CatalogImpl.parse(CatalogImpl.java:295) ~[na:na]
at java.xml/javax.xml.catalog.CatalogImpl.load(CatalogImpl.java:171) ~[na:na]
at java.xml/javax.xml.catalog.CatalogManager.catalog(CatalogManager.java:73) ~[na:na]
at java.xml/javax.xml.catalog.CatalogManager.catalogResolver(CatalogManager.java:119) ~[na:na]
at com.sun.xml.ws.util.xml.XmlCatalogUtil.createCatalogResolver(XmlCatalogUtil.java:125) ~[jaxws-rt-2.3.0.jar:2.3.0]
at com.sun.xml.ws.util.xml.XmlCatalogUtil.createDefaultCatalogResolver(XmlCatalogUtil.java:105) ~[jaxws-rt-2.3.0.jar:2.3.0]
... 38 common frames omitted

如何克服此兼容性错误?

最佳答案

我在使用 cxf-codegen-plugin 3.3.5 时遇到了同样的问题,解决方案是使用 cxf 的依赖项而不是 com.sun.xml.ws(或任何其他 rt)。

<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.3.5</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>3.3.5</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>3.3.5</version>
</dependency>

关于java - 使用 WSDL2Java 从 WSDL 生成的源使用 java 11 上已弃用的 API javax xml ws 生成类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58336599/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com