Camel CXF: IllegalArgumentException parameters should be of type X

强颜欢笑 提交于 2019-12-11 00:27:30

问题


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;
}

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");

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)
    ...

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?

Thanks a lot!


回答1:


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

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



来源:https://stackoverflow.com/questions/34017923/camel-cxf-illegalargumentexception-parameters-should-be-of-type-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!