Eclipse Web Service Client向导和CXF

时间:2013-05-24 18:34:49

标签: eclipse web-services cxf webservices-client

我正在尝试使用Eclipse Juno SR2向导创建Web服务客户端。该服务已正确部署并在Glassfish 3.1.2服务器上运行,我可以看到WSDL文件或使用Axis创建客户端。 如果我尝试使用CXF(尝试过CXF 2.6.8和2.7.5)在为GLassfish 3.1.2创建的动态Web项目中创建客户端,则会出现问题:

Loading FrontEnd jaxws ...
Loading DataBinding jaxb ...
wsdl2java -client -d /Users/dude/Documents/SOA/workspace/gf/.cxftmp/src -classdir /Users/dude/Documents/SOA/workspace/gf/build/classes -p http://testservice.csiaf.unifi.it/=it.unifi.csiaf.testservice -impl -validate -exsh false -dns true -dex true -wsdlLocation http://localhost:8888/TestServiceGlassfish/TeamsService?wsdl -verbose -defaultValues -fe jaxws -db jaxb -wv 1.1 http://localhost:8888/TestServiceGlassfish/TeamsService?wsdl
wsdl2java - Apache CXF 2.6.8

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/dude/glassfish3/glassfish/modules/weld-osgi-bundle.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/apache-cxf-2.6.8/lib/slf4j-jdk14-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.

WSDLToJava Error: org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create wsdl definition from : http://localhost:8888/TestServiceGlassfish/TeamsService?wsdl
Caused by : WSDLException: faultCode=PARSER_ERROR: java.lang.RuntimeException: Cannot create a secure XMLInputFactory 

org.apache.cxf.tools.common.ToolException: org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create wsdl definition from : http://localhost:8888/TestServiceGlassfish/TeamsService?wsdl
Caused by : WSDLException: faultCode=PARSER_ERROR: java.lang.RuntimeException: Cannot create a secure XMLInputFactory 
    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:420)
    at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103)
    at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113)
    at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86)
    at org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:184)
Caused by: org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create wsdl definition from : http://localhost:8888/TestServiceGlassfish/TeamsService?wsdl
Caused by : WSDLException: faultCode=PARSER_ERROR: java.lang.RuntimeException: Cannot create a secure XMLInputFactory 
    at org.apache.cxf.wsdl11.WSDLDefinitionBuilder.parseWSDL(WSDLDefinitionBuilder.java:97)
    at org.apache.cxf.wsdl11.WSDLDefinitionBuilder.build(WSDLDefinitionBuilder.java:69)
    at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build(JAXWSDefinitionBuilder.java:82)
    at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build(JAXWSDefinitionBuilder.java:59)
    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:198)
    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:164)
    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:412)
    ... 4 more
Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: java.lang.RuntimeException: Cannot create a secure XMLInputFactory
    at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:243)
    at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:192)
    at org.apache.cxf.wsdl11.WSDLDefinitionBuilder.parseWSDL(WSDLDefinitionBuilder.java:78)
    ... 10 more
Caused by: java.lang.RuntimeException: Cannot create a secure XMLInputFactory
    at org.apache.cxf.staxutils.StaxUtils.createXMLInputFactory(StaxUtils.java:299)
    at org.apache.cxf.staxutils.StaxUtils.getXMLInputFactory(StaxUtils.java:254)
    at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1423)
    at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1317)
    at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:233)
    ... 12 more

如果我尝试将wsdl2java作为命令行执行,它就可以工作并创建.java文件:

macpro:glassfish3 dude$ /usr/local/apache-cxf-2.6.8/bin/wsdl2java -client -d /Users/dude/Documents/SOA/workspace/gf/.cxftmp/src -classdir /Users/dude/Documents/SOA/workspace/gf/build/classes -p http://testservice.csiaf.unifi.it/=it.unifi.csiaf.testservice -impl -validate -exsh false -dns true -dex true -wsdlLocation http://localhost:8888/TestServiceGlassfish/TeamsService?wsdl -verbose -defaultValues -fe jaxws -db jaxb -wv 1.1 http://localhost:8888/TestServiceGlassfish/TeamsService?wsdl
Loading FrontEnd jaxws ...
Loading DataBinding jaxb ...
wsdl2java -client -d /Users/dude/Documents/SOA/workspace/gf/.cxftmp/src -classdir /Users/dude/Documents/SOA/workspace/gf/build/classes -p http://testservice.csiaf.unifi.it/=it.unifi.csiaf.testservice -impl -validate -exsh false -dns true -dex true -wsdlLocation http://localhost:8888/TestServiceGlassfish/TeamsService?wsdl -verbose -defaultValues -fe jaxws -db jaxb -wv 1.1 http://localhost:8888/TestServiceGlassfish/TeamsService?wsdl
wsdl2java - Apache CXF 2.6.8

我认为Eclipse + CXF组合中存在一些问题,因为命令行有效,但我不知道如何解决它。有什么想法吗?

5 个答案:

答案 0 :(得分:10)

您需要确保正在拾取Woodstox 4.2.0。或者,将系统属性org.apache.cxf.stax.allowInsecureParser设置为true

答案 1 :(得分:2)

尝试从glassfish\modules目录中删除这两个jar文件:

  • woodstox核-asl.jar
  • stax2-api.jar文件

我认为它会阻止CXF项目中的2个JAR文件(woodstox和stax2)在部署后使用。

答案 2 :(得分:0)

如果它作为依赖存在于某处,请尝试排除它,并使用Woodstox 4.2.0:

<artifactId>wstx-asl</artifactId>
<groupId>org.codehaus.woodstox</groupId>

答案 3 :(得分:0)

我在JDeveloper中遇到了同样的问题,并通过在类路径中添加“woodstox-core-asl-4.2.1.jar”解决了这个问题。

答案 4 :(得分:0)

我面临着同样的问题,但是将其部署到网络领域,经过几个小时的研究,找出了woodstox的确切版本,即下面

<dependency>
    <groupId>org.codehaus.woodstox</groupId>
    <artifactId>woodstox-core-asl</artifactId>
    <version>4.2.0</version>
</dependency>

https://bugs.eclipse.org/bugs/show_bug.cgi?id=409070链接也有助于解决问题。

Java和.Net客户端都工作正常。