有没有办法让 CXF 在与 Web 服务通信时忽略 maxElementCount



我正在使用SPring 3.2.11.RELEASE和CXF 2.7.18。 我的 SPring 应用程序上下文文件中有这个,这是与 Web 服务通信所必需的......

    <jaxws:client id="myWebServiceClient"
            serviceClass="org.mainco.bsorg.MyWebService"
            address="${wsdl.url}"
    />
    <cxf:bus>
            <cxf:properties>
            <entry key="org.apache.cxf.stax.maxElementCount" value="10000000"/>
            </cxf:properties>
    </cxf:bus>

在我的 Maven pom.xml 文件中,我为插件配置了这个......

                    <plugin>
                            <groupId>org.codehaus.mojo</groupId>
                            <artifactId>jaxws-maven-plugin</artifactId>
                            <version>2.4.1</version>
                            <executions>
                                    <execution>
                                            <goals>
                                                    <goal>wsimport</goal>
                                            </goals>
                                            <configuration>
                                                    <target>2.1</target>
                                                    <wsdlDirectory>${basedir}/src/wsdl</wsdlDirectory>
                                                    <sourceDestDir>${basedir}/src/main/java</sourceDestDir>
                                                    <packageName>org.mainco.bsorg</packageName>
                                                    <vmArgs>
                                                            <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
                                                    </vmArgs>
                                            </configuration>
                                    </execution>
                            </executions>
                    </plugin>

毫无疑问,当我对我的 Web 服务执行特定调用时,我会收到此错误......

07:16:26,088 WARNING [org.apache.cxf.phase.PhaseInterceptorChain] (org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-2) Interceptor for {http://mainco.org/bsorg/}MyWebServiceService#{http://mainco.org/bsorg/}searchOrgs has thrown exception, unwinding now: org.apache.cxf.interceptor.Fault: Unmarshalling Error: Maximum Number of Child Elements limit (50000) Exceeded
        at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:907) [cxf-rt-databinding-jaxb-2.7.15.jar:2.7.15]
        at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:711) [cxf-rt-databinding-jaxb-2.7.15.jar:2.7.15]
        at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:172) [cxf-rt-databinding-jaxb-2.7.15.jar:2.7.15]
        at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:107) [cxf-api-2.7.15.jar:2.7.15]
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272) [cxf-api-2.7.15.jar:2.7.15]
        at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:849) [cxf-api-2.7.15.jar:2.7.15]
        at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1626) [cxf-rt-transports-http-2.7.15.jar:2.7.15]
        at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1515) [cxf-rt-transports-http-2.7.15.jar:2.7.15]
        at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1317) [cxf-rt-transports-http-2.7.15.jar:2.7.15]
        at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56) [cxf-api-2.7.15.jar:2.7.15]
        at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:632) [cxf-rt-transports-http-2.7.15.jar:2.7.15]
        at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62) [cxf-api-2.7.15.jar:2.7.15]
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272) [cxf-api-2.7.15.jar:2.7.15]
        at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:572) [cxf-api-2.7.15.jar:2.7.15]
如果我将 maxElementCount 值从"10000000"更改为"1000000

",则会出现上述错误,并显示"超出最大子元素数限制 (1000000("。 有没有办法让 CXF 完全忽略 maxElementCount 限制? 不得不摆弄最大值是一种痛苦。 我愿意使用natoher技术在Spring中配置Web服务,但是如果您建议使用,请提供我需要的Maven和Spring配置。

您是否尝试过设置 org.apache.cxf.stax.maxChildElements 属性?

您似乎正在尝试覆盖错误的属性maxElementCount而不是maxChildElements

请参阅此处的文档。

相关内容

  • 没有找到相关文章