如何解决Camel-cxf SOAP响应上的IndexOutOfBoundsException
我正在尝试使Cxf骆驼路线可行。
可以在here中找到WSDL。
SoapJaxbDataFormat soapformat = new SoapJaxbDataFormat("com.cLeverbuilder.bookservice",new ServiceInterfaceStrategy(BookService.class,true));
from("timer:cxfTimer?repeatCount=1")
.routeId("cxf-route")
.bean(Bean.class,"getBook")
.marshal(soapformat)
.convertBodyTo(String.class)
.log("Request: ${body}")
.setHeader(CxfConstants.OPERATION_NAME,constant("GetBook"))
.setHeader(CxfConstants.OPERATION_NAMESPACE,constant("http://www.cLeverbuilder.com/BookService/"))
.to("cxf://http://localhost:8088/BookService"
+ "?serviceClass=com.cLeverbuilder.bookservice.BookService"
+ "&wsdlURL=/wsdl/BookService.wsdl")
.log("Response: ${body}");
被记录的请求如下:
<?xml version="1.0" encoding="UTF-8"?>
<ns2:Envelope xmlns:ns2="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns3="http://www.cLeverbuilder.com/BookService/">
<ns2:Body>
<ns3:GetBook>
<ID>12345</ID>
</ns3:GetBook>
</ns2:Body>
</ns2:Envelope>
我可以在SOAPUI中看到请求确实到达并且该响应被发送回去:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:book="http://www.cLeverbuilder.com/BookService/">
<soapenv:Header/>
<soapenv:Body>
<book:GetBookResponse>
<ID>12345</ID>
<Title>How to build a boat?</Title>
<Author>Noah</Author>
</book:GetBookResponse>
</soapenv:Body>
</soapenv:Envelope>
但是回到骆驼时,我得到了这个异常:
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:373)
at java.base/java.util.ArrayList.get(ArrayList.java:427)
at org.apache.cxf.jaxws.interceptors.HolderInInterceptor.handleMessage(HolderInInterceptor.java:67)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:810)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1697)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream$1.run(HTTPConduit.java:1192)
at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$3.run(AutomaticWorkQueueImpl.java:412)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$AWQThreadFactory$1.run(AutomaticWorkQueueImpl.java:345)
at java.base/java.lang.Thread.run(Thread.java:832)
我期望POJO返回或者只是一个String。我不太确定这是怎么回事。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。