我尝试在JBOSS FUSE中使用POJO模式进行代理,并且真正的Web服务正在执行。
但是客户端会遇到异常
Caused by: org.apache.cxf.binding.soap.SoapFault: [B cannot be cast to [Ljava.lang.Object;
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.unmarshalFault(Soap11FaultInInterceptor.java:84)
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:51)
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:40)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:113)
at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:69)
at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:34)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:835)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1612)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1503)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1310)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:628)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:565)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:474)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:377)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:330)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135)
... 2 more
我的Blueprint.xml
我可以使用代理和处理器调用真正的Web服务。
但是,响应将返回给客户。
我是否需要在处理器或蓝图中执行任何操作来处理这种情况。
<cxf:cxfEndpoint xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf" id="webserviceProxy"
address="http://localhost:8383/service_sample_proxy/services_proxy/proxyport"
endpointName="tns:ComplexServiceImplPort"
serviceName="tns:ComplexServiceImplService"
serviceClass="webservice.ComplexServiceImpl"
wsdlURL="wsdl/complexserviceimpl.wsdl"
xmlns:tns="http://webservice/" />
<camelContext id="blueprintContext"
trace="false"
xmlns="http://camel.apache.org/schema/blueprint">
<endpoint id="callRealWebService" uri="jetty:http://localhost:8080/service_sample/services/ComplexServiceImplPort?throwExceptionOnFailure=false"/>
<route id="httpBridge">
<from uri="cxf:bean:webserviceProxy?dataFormat=POJO"/>
<process ref="requestDataProcessor"/>
<to ref="callRealWebService"/>
</route>
</camelContext>
<bean id="requestDataProcessor" class="org.fusesource.example.RequestDataProcessor"/>
我的Processor.java
public class RequestDataProcessor implements Processor {
public void process(Exchange exchange) throws Exception {
String temp = exchange.getIn().getBody(String.class);
RequestData temp = exchange.getIn().getBody(RequestData.class);
String SOAPContent = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"+
"<soap:Body>"+
"<ns2:sampleMethod xmlns:ns2=\"http://webservice/\">"+
"<arg0>"+
"<name>" +temp.getName()+" PROXY CONTENT</name>"+
"<no>"+temp.getNo()+"</no>"+
"<salary>"+temp.getSalary()+" PROXY CONTENT</salary>"+
"</arg0>"+
"</ns2:sampleMethod>"+
"</soap:Body>"+
"</soap:Envelope>";
exchange.getOut().setBody(SOAPContent);
exchange.getOut().setHeaders(exchange.getIn().getHeaders());
}
}
SOAPUI中的Resonse
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>[B cannot be cast to [Ljava.lang.Object;</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
我遇到了问题,代理收到的格式不同。但是,我不知道如何解决这个问题。
答案 0 :(得分:0)
而不是: String temp = exchange.getIn()。getBody(String.class);
尝试以下方法:
MessageContentsList list = exchange.getIn().getBody(MessageContentsList.class);
String temp = list.get(0);