Camel CXF:IllegalArgumentException 参数应为 X 类型 [英] Camel CXF: IllegalArgumentException parameters should be of type X

查看:38
本文介绍了Camel CXF:IllegalArgumentException 参数应为 X 类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用 CXF 调用服务的 Camel 项目.这些服务是通过 wsdl 定义的,我无法对其进行修改.我用 wsdl2java 生成了类:我会有很多其他的远程服务,它们可能经常变化,所以我希望尽可能多地生成 POJO 和接口.

I'm working on a Camel project calling services with CXF. The services are defined through a wsdl and which I cannot modify it. I generated classes with wsdl2java: I will have many other remote services, they may change often, so I want to have the POJOs and interfaces to be generated as much as possible.

我生成的界面如下所示:

My generated interface looks like this:

@WebService(targetNamespace = "http://service.company.fr", name = "myService")
@XmlSeeAlso({ObjectFactory.class})
public interface MyService {

    @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
    @WebResult(name = "sendMessageResponse", targetNamespace = "http://service.company.fr", partName = "parameters")
    @WebMethod
    SendMessageResponse sendLetter(
            @WebParam(partName = "parameters", name = "sendLetter", targetNamespace = "http://service.company.fr")
            SendLetter parameters
    ) throws MessageServiceException_Exception;

    @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
    @WebResult(name = "sendMessageResponse", targetNamespace = "http://service.company.fr", partName = "parameters")
    @WebMethod
    SendMessageResponse sendWebNotification(
            @WebParam(partName = "parameters", name = "sendWebNotification", targetNamespace = "http://service.company.fr")
            SendWebNotification parameters
    ) throws MessageServiceException_Exception;

    @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
    @WebResult(name = "sendMessageResponse", targetNamespace = "http://service.company.fr", partName = "parameters")
    @WebMethod
    SendMessageResponse sendEmail(
            @WebParam(partName = "parameters", name = "sendEmail", targetNamespace = "http://service.company.fr")
            SendEmail parameters
    ) throws MessageServiceException_Exception;
}

我在一个 XML 文件中定义了 CXF 端点,如下所示:

I defined the CXF Endpoint in an XML file, like this :

  <cxf:cxfEndpoint id="serviceEndpoint"
                   address="http://localhost:9081/soap/service"
                   serviceClass="fr.company.service.MyService">
    <cxf:properties>
      <entry key="dataFormat" value="POJO"/>
    </cxf:properties>
  </cxf:cxfEndpoint>

最后,我以骆驼路线调用服务:

And finally, I am calling the service in a Camel route :

from(URI_SERVICE)
                .process(sendEmailBodyProcessor)
                .to("cxf:bean:serviceEndpoint");

sendEmailBodyProcessor 使用 SendEmail 对象设置正文(对应于接口中的第三个服务).如果我只保留我在界面中使用的服务,它可以工作,但如果我离开其他服务,我会收到此错误:

The sendEmailBodyProcessor sets the body with a SendEmail object (corresponding to the 3rd service from the interface). If I leave only the service I use in the interface, it works, but if I leave the other services, I get this error:

java.lang.IllegalArgumentException: Part {http://service.company.fr}parameters should be of type fr.company.service.SendLetter, not fr.company.service.SendEmail
    at org.apache.cxf.jaxb.io.DataWriterImpl.checkPart(DataWriterImpl.java:292)
    at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:220)
    at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:117)
    at org.apache.cxf.wsdl.interceptors.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
    ...

我尝试使用 operationNamemethod 等标头,但无法正常工作...

I tried using headers like operationName or method etc. but I can't get it to work...

有人知道如何让它工作吗?

Has anyone a clue on how I can get it to work?

非常感谢!

推荐答案

我终于找到解决问题的方法了!...

I finally found how to solve my problem!...

就我而言,operationName 还不够,我还需要添加 operationNamespace = "http://service.company.fr"

In my case, operationName was not enough, I needed to add operationNamespace = "http://service.company.fr" as well!

这篇关于Camel CXF:IllegalArgumentException 参数应为 X 类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆