繁体   English   中英

通过 Camel cxf 组件连接 SOAP 端点时,WrapperClassOutInterceptor 无法转换为 java.lang.String 错误

[英]Cannot be cast to java.lang.String error at WrapperClassOutInterceptor when connecting SOAP endpoint through Camel cxf component

我正在执行调用 SOAP web 服务并处理响应的实现。

我从下面的帖子开始,当它连接到 web 服务端点时出现以下错误

错误:WrapperClassOutInterceptor 中的“com.cleverbuilder.bookservice.GetBook 无法转换为 java.lang.String”。

这可能是什么原因?

请注意http://localhost:8423/test/BookService已启动并且工作正常。 我在 SOAP 路由器之外进行了测试,它在那里工作正常。

喜欢在日志下面突出显示

  • 车身类型:com.cleverbuilder.bookservice.GetBook,
  • 身体:

     <?xml version="1.0" encoding="UTF-8" standalone="yes"?><ns2:GetBook xmlns:ns2="http://www.cleverbuilder.com/BookService/"> <ID>12345</ID></ns2:GetBook>,
  • 出:null

日志:

06:28:32,381 INFO  [output >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 5] (default task-1) Exchange[Id: ID-namal-pc-1569977860461-1-1, ExchangePattern: InOut, Properties: {CamelCreatedTimestamp=Wed Oct 02 06:28:32 IST 2019, CamelExternalRedelivered=false, CamelFilterMatched=true, CamelMessageHistory=[DefaultMessageHistory[routeId=route7, node=choice8], DefaultMessageHistory[routeId=route7, node=to23], DefaultMessageHistory[routeId=route5, node=to11], DefaultMessageHistory[routeId=route5, node=setBody1], DefaultMessageHistory[routeId=route5, node=to12], DefaultMessageHistory[routeId=route5, node=bean1], DefaultMessageHistory[routeId=route5, node=to13], DefaultMessageHistory[routeId=route5, node=setHeader1], DefaultMessageHistory[routeId=route5, node=to14], DefaultMessageHistory[routeId=route5, node=setHeader2], DefaultMessageHistory[routeId=route5, node=to15]], CamelToEndpoint=log://output%20%3E%3E%3E%3E%3E%3E%3E%3E%3E%3E%3E%3E%3E%3E%3E%3E%3E%3E%3E%3E%3E%3E%3E%3E%3E%3E%3E%3E%3E%3E%3E%205?showAll=true}, Headers: {breadcrumbId=ID-namal-pc-1569977860461-1-1, clientId=magnify, doLogFiles=false, dontLogErrorFiles=false, messageId=soapExecutor, messageName=SOAPExecutor, operationName=GetBook, operationNamespace=http://www.cleverbuilder.com/BookService/, routeId=direct-soap, specialRq=true, uber-trace-id=, uberctx-user-name=null, useCommonService=false}, BodyType: com.cleverbuilder.bookservice.GetBook, Body: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><ns2:GetBook xmlns:ns2="http://www.cleverbuilder.com/BookService/">    <ID>12345</ID></ns2:GetBook>, Out: null: ]
06:28:32,424 WARNING [org.apache.cxf.phase.PhaseInterceptorChain] (default task-1) Interceptor for {http://www.cleverbuilder.com/BookService/}BookServicePortImplService#{http://www.cleverbuilder.com/BookService/}GetBook has thrown exception, unwinding now: org.apache.cxf.interceptor.Fault: com.cleverbuilder.bookservice.GetBook cannot be cast to java.lang.String
    at org.apache.cxf.jaxws.interceptors.WrapperClassOutInterceptor.handleMessage(WrapperClassOutInterceptor.java:107)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
    at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:537)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:439)
    at org.apache.camel.component.cxf.CxfProducer.process(CxfProducer.java:133)
    at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:148)
    at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:138)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
    at org.apache.camel.component.direct.DirectBlockingProducer.process(DirectBlockingProducer.java:53)
    at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:148)
    at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
    at org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:117)
    at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
    at org.apache.camel.component.direct.DirectBlockingProducer.process(DirectBlockingProducer.java:53)
    at org.apache.camel.processor.SharedCamelInternalProcessor.process(SharedCamelInternalProcessor.java:186)
    at org.apache.camel.processor.SharedCamelInternalProcessor.process(SharedCamelInternalProcessor.java:86)
    at org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:541)
    at org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:506)
    at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:369)
    at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:506)
    at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:264)
    at org.apache.camel.impl.DefaultProducerTemplate.requestBodyAndHeaders(DefaultProducerTemplate.java:355)

SoapRouter.java @ApplicationScoped @ContextName("camel_cdi_context") public class SoapRouter 扩展 RouteBuilder {

@Override
public void configure() throws Exception {

    from("direct:soap")

        .to("log:output >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 1?showAll=true")
            .setBody(constant("12345"))

        .to("log:output >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 2?showAll=true")
            .bean(GetBookRequestBuilder.class)

        .to("log:output >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 3?showAll=true")
            .setHeader(CxfConstants.OPERATION_NAME, constant("GetBook"))

        .to("log:output >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 4?showAll=true")
            .setHeader(CxfConstants.OPERATION_NAMESPACE, constant("http://www.cleverbuilder.com/BookService/"))

        .to("log:output >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 5?showAll=true")

        .to("cxf://http://localhost:8423/test/BookService?serviceClass=com.cleverbuilder.bookservice.BookService&wsdlURL=/wsdl/BookService.wsdl")

        .to("log:output >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 6?showAll=true");

}

}

GetBookRequestBuilder.java public class GetBookRequestBuilder {

public GetBook getBook(String id) {
    GetBook request = new GetBook();
    request.setID(id);

    return request;
}

}

我想出了一个带有 dataFormat=PAYLOAD 的选项,如下所述。 无论如何打开更多选择。

对于 SoapJaxbDataFormat,您需要导入 camel-soap 依赖项。

例如:

String WS_URI = "cxf://http://myserver/customerservice?serviceClass=com.example.customerservice&dataFormat=MESSAGE";
SoapJaxbDataFormat soapDF = new SoapJaxbDataFormat("com.example.customerservice", new ServiceInterfaceStrategy(CustomerService.class));
from("direct:customerServiceClient")
  .onException(Exception.class)
    .handled(true)
    .unmarshal(soapDF)
  .end()
  .marshal(soapDF)
  .to(WS_URI)
  .unmarshal(soapDF);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM