Apache骆驼:带肥皂的CXF:indexoutofBoundSexception:from handleInterceptor handlemessage(line67)。如何修复?
我正在使用Apache Camel路由,需要执行SOAP API调用,用于SOAP API,我正在使用CXF库,而在使用它时,我
09:45:12.430 [default-workqueue-1] WARN org.apache.cxf.phase.PhaseInterceptorChain - Interceptor for {urn:dictionary:com.chargepoint.webservices}chargepointservices#{urn:dictionary:com.chargepoint.webservices}getTransactionData has thrown exception, unwinding now
java.lang.IndexOutOfBoundsException: Index 1 out of bounds for length 1
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
at java.base/java.util.Objects.checkIndex(Objects.java:372)
at java.base/java.util.ArrayList.get(ArrayList.java:459)
at org.apache.cxf.jaxws.interceptors.HolderInInterceptor.handleMessage(HolderInInterceptor.java:67)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:808)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1701)
会遇到错误 -我的路线 -
from("direct:testSoapStart")
.log("TestSoapApiRoute Initiated.")
.process(this.soapRequestProcessor)
//.setHeader(OPERATION_NAME, constant("getCPNInstances"))
//.setHeader(OPERATION_NAME, constant("getOrgsAndStationGroups"))
.setHeader(OPERATION_NAME, constant("getTransactionData"))
.setHeader(OPERATION_NAMESPACE, constant("urn:dictionary:com.chargepoint.webservices"))
.toD("URL?"
+ "serviceClass=dictionary.com_chargepoint_webservices.Chargepointservices"
+ "&wsdlURL=/wsdl/cp_api_5.1.wsdl")
.log("body :: ${body}")
.process(this.soapResponseProcessor)
.log("TestSoapApiRoute Completed.")
.end();
在SoaprequestProcessor中 身体 -
exchange.getIn().setHeader(Header.HEADER_LIST, soapHeaders);
exchange.getIn().setBody(new Object[]{new GetTransDataSearchRequest()});
我不知道为什么在holderininterceptor中失败了,食口列表的尺寸总是一个,所有元素都是无效的。这引起了问题。我没有关于此食客对象的任何信息,请在此方面提供帮助 -
还是需要替换HolderinInterceptor?如果是这样,我们该如何替换?
提前致谢。
I am using Apache Camel Route, where I need to perform Soap API call, for SOAP api, i am using Cxf library, while using it I am getting error like below -
09:45:12.430 [default-workqueue-1] WARN org.apache.cxf.phase.PhaseInterceptorChain - Interceptor for {urn:dictionary:com.chargepoint.webservices}chargepointservices#{urn:dictionary:com.chargepoint.webservices}getTransactionData has thrown exception, unwinding now
java.lang.IndexOutOfBoundsException: Index 1 out of bounds for length 1
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
at java.base/java.util.Objects.checkIndex(Objects.java:372)
at java.base/java.util.ArrayList.get(ArrayList.java:459)
at org.apache.cxf.jaxws.interceptors.HolderInInterceptor.handleMessage(HolderInInterceptor.java:67)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:808)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1701)
My Route -
from("direct:testSoapStart")
.log("TestSoapApiRoute Initiated.")
.process(this.soapRequestProcessor)
//.setHeader(OPERATION_NAME, constant("getCPNInstances"))
//.setHeader(OPERATION_NAME, constant("getOrgsAndStationGroups"))
.setHeader(OPERATION_NAME, constant("getTransactionData"))
.setHeader(OPERATION_NAMESPACE, constant("urn:dictionary:com.chargepoint.webservices"))
.toD("URL?"
+ "serviceClass=dictionary.com_chargepoint_webservices.Chargepointservices"
+ "&wsdlURL=/wsdl/cp_api_5.1.wsdl")
.log("body :: ${body}")
.process(this.soapResponseProcessor)
.log("TestSoapApiRoute Completed.")
.end();
In My SoapRequestProcessor - I'am adding Header and the body -
exchange.getIn().setHeader(Header.HEADER_LIST, soapHeaders);
exchange.getIn().setBody(new Object[]{new GetTransDataSearchRequest()});
I don't know why it's failing in HolderInInterceptor, The OutHolders List is having size one always, and all elements are null. Which is causing the problem. I am not having any information about this outHolders object, please help in this -
Or Do i need to replace the HolderInInterceptor ? If so How can we replace it ?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到了同样的问题,并没有答案找到了这个问题,因此我想分享我的解决方案。
我错误的原因是,生成的接口具有无效方法而不是正确的返回类型。输入对象字段和输出对象字段均作为void方法的输入参数添加。我的路线仅设置了reqeust参数,而不是为响应参数准备持有人。
从错误
indexoutofBoundSexception中:索引1的长度为1
我猜想您在请求元素中有一个字段(index = 0),因此它试图找到第一个输出param holder(HolderInterInterceptor。 Java线67)。仅当操作在其定义中没有输出消息时,才能生成空隙方法。
因此,如果将接口方法正确生成为void方法,则应修改与
javax.xml.ws.hsholder< java.lang.lang.string>
等持有人设置所有输出的路由。代码> .to()方法。就我而言,我既有输入和输出消息,但仍会生成无效方法。我不知道它是在CXF侧的错误还是WSDL在我从Web服务侧未正确定义的WSDL,但问题是由于消息中使用的元素和名称中使用的元素的名称相同而引起的。操作。
这是一个GitHub项目,我在其中展示我的问题
I had this same problem and found this question without an answer, so I want to share my solution.
The reason for my error was, that the generated interface had void methods instead of proper return type. The input object fields and output object fields were all added as input parameters of the void method. And my route was setting only the reqeust parameters and not prepareing holders for response parameters.
From the error
IndexOutOfBoundsException: Index 1 out of bounds for length 1
i am guessing you had a single field(index=0) in the request element so its trying to find the first output param holder (HolderInInterceptor.java line 67).Generating void methods should be only when the operation does not have an output message in its definition.
So if the interface methods are correctly generated as void methods, you should modify the route to set all the output fileds with holders like
javax.xml.ws.Holder<java.lang.String>
before the.to()
method.In my case I had both input and output messages, but it still generated void methods. I don't know if its a bug on the CXF side or the wsdl isn't correctly defined on the web service side I downloaded it from, but the problem was caused by having an identical name for the element used in message and the name of the operation.
Here is a github project where i showcase my problem Java CXF wsdl2java generation