在 spring 引导应用程序中调用 Apache CXF 客户端时无法创建安全的 XMLInputFactory
Cannot create a secure XMLInputFactory when calling Apache CXF Client in spring boot application
我正在尝试在我的 spring 启动应用程序中使用一项服务。这个确切的客户端在 netbeans 和一个使用 spring 3 MVC 的旧项目中工作正常但是当我尝试调用相同的方法时我得到 javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: java.lang.RuntimeException: Cannot create a secure XMLInputFactory
.
我搜索了很多并尝试了不同的答案,但没有成功!这些是我试过的关于 Whosebug 的一些问题:
CXF web service client: "Cannot create a secure XMLInputFactory"
java.lang.RuntimeException: Cannot create a secure XMLInputFactory when deploying on Glassfish
Cannot create a secure XMLInputFactory
Cannot create a secure XMLInputFactory when calling Apache CXF Client from Plain Java
虽然通过 VM 选项以允许不太安全的解析器对我来说不是解决方案,但我尝试了。当我添加 -Dorg.apache.cxf.stax.allowInsecureParser=1
时,第一行代码没有抛出指定的异常,但在第二行,当我尝试获取端口时,将抛出 java.lang.NoSuchFieldError: QUALIFIED
!
服务调用代码:
MessageRelayService messageRelayService = new MessageRelayService();
MessageRelay msgService = messageRelayService.getMessageRelayPort();
CountResult countResult = msgService.getReceivedMessageCount(USERNAME, PASSWORD);
我的pom(为简洁省略了部分):
<properties>
...
<java.version>1.8</java.version>
<cxf.version>3.0.0</cxf.version>
<swagger.version>2.6.0</swagger.version>
<purchase.version>1.2.4</purchase.version>
<spring-cloud.version>Camden.SR2</spring-cloud.version>
...
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencies>
.
.
.
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-local</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-http</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-impl</artifactId>
<version>1.2.13</version>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>${cxf.version}</version>
</dependency>
.
.
.
</dependencies>
...
如有任何帮助,我们将不胜感激。
经过大量搜索并在@pringi 的帮助下尝试了各种方法后,我回到我的 pom 并发现了问题,所以我想写一个答案,也许有一天它会对某人有所帮助!
问题是我的 pom 中有一些不需要的依赖项,可以删除它们,但它们与 cxf 冲突!所以我删除了这些依赖项,瞧!
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-local</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-http</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-impl</artifactId>
<version>1.2.13</version>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.neethi</groupId>
<artifactId>neethi</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-api</artifactId>
<version>1.2.13</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.schema</groupId>
<artifactId>XmlSchema</artifactId>
<version>1.4.2</version>
</dependency>
感谢大家!
我正在尝试在我的 spring 启动应用程序中使用一项服务。这个确切的客户端在 netbeans 和一个使用 spring 3 MVC 的旧项目中工作正常但是当我尝试调用相同的方法时我得到 javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: java.lang.RuntimeException: Cannot create a secure XMLInputFactory
.
我搜索了很多并尝试了不同的答案,但没有成功!这些是我试过的关于 Whosebug 的一些问题:
CXF web service client: "Cannot create a secure XMLInputFactory"
java.lang.RuntimeException: Cannot create a secure XMLInputFactory when deploying on Glassfish
Cannot create a secure XMLInputFactory
Cannot create a secure XMLInputFactory when calling Apache CXF Client from Plain Java
虽然通过 VM 选项以允许不太安全的解析器对我来说不是解决方案,但我尝试了。当我添加 -Dorg.apache.cxf.stax.allowInsecureParser=1
时,第一行代码没有抛出指定的异常,但在第二行,当我尝试获取端口时,将抛出 java.lang.NoSuchFieldError: QUALIFIED
!
服务调用代码:
MessageRelayService messageRelayService = new MessageRelayService();
MessageRelay msgService = messageRelayService.getMessageRelayPort();
CountResult countResult = msgService.getReceivedMessageCount(USERNAME, PASSWORD);
我的pom(为简洁省略了部分):
<properties>
...
<java.version>1.8</java.version>
<cxf.version>3.0.0</cxf.version>
<swagger.version>2.6.0</swagger.version>
<purchase.version>1.2.4</purchase.version>
<spring-cloud.version>Camden.SR2</spring-cloud.version>
...
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencies>
.
.
.
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-local</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-http</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-impl</artifactId>
<version>1.2.13</version>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>${cxf.version}</version>
</dependency>
.
.
.
</dependencies>
...
如有任何帮助,我们将不胜感激。
经过大量搜索并在@pringi 的帮助下尝试了各种方法后,我回到我的 pom 并发现了问题,所以我想写一个答案,也许有一天它会对某人有所帮助!
问题是我的 pom 中有一些不需要的依赖项,可以删除它们,但它们与 cxf 冲突!所以我删除了这些依赖项,瞧!
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-local</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-http</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-impl</artifactId>
<version>1.2.13</version>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.neethi</groupId>
<artifactId>neethi</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-api</artifactId>
<version>1.2.13</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.schema</groupId>
<artifactId>XmlSchema</artifactId>
<version>1.4.2</version>
</dependency>
感谢大家!