问题描述
我正在尝试使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 (将#修改为@)