Search code examples
javasoapwsdlapache-camelcxf

Camel CXF throws Part{example.com}parameters should be of type X not Y


I am new to SOAP and can't figure out what the problem is. I have looked at similar SO post but unfortunately it doesn't help. The error message is:

WARNING: Interceptor for {http://bbbts/Service}Service#{http://bbbts/Service}ConfirmAStatus has thrown exception, unwinding now
IllegalArgumentException: Part {http://bbbts/Service}parameters should be of type package.ConfirmAStatusResponse, not package.ConfirmAStatus

I have configured the endpoint in Camel as follows:

    CxfEndpoint cxfEndpoint = new CxfEndpoint();
    cxfEndpoint.setAddress("http://0.0.0.0:8888/aaans/services/Service");
    cxfEndpoint.setWsdlURL("Service.wsdl");
    cxfEndpoint.setCamelContext(camelContext);
    cxfEndpoint.setBus(bus);
    cxfEndpoint.setServiceNameString("bbbts:Service");
    cxfEndpoint.setDefaultOperationName("ConfirmAStatus"); 
    cxfEndpoint.setDefaultOperationNamespace("http://bbbts/Service");

    try { 
    cxfEndpoint.setServiceClass("package.Service"); 
    } catch (ClassNotFoundException e1) { 
    } 
    cxfEndpoint.setDataFormat(DataFormat.POJO);  

I have generated the Service class via cxf-codegen and it looks like this:

@WebService(targetNamespace = "http://bbbts/Service", name = "Service")
@XmlSeeAlso({ObjectFactory.class})
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public interface Service {

@WebMethod(operationName = "ConfirmAStatus", action = "http://aaans/2012/nsv1/ConfirmARecallStatus")
@Action(input = "http://aaans/2012/nsv1/ConfirmProductBatchRecallStatus", output = "http://aaans/2012/nsv1/ConfirmAStatusResponse")
@WebResult(name = "ConfirmAStatusResponse", targetNamespace = "http://aaans/2012/", partName = "parameters")
public ConfirmAStatusResponse confirmAStatus(
    @WebParam(partName = "parameters", name = "ConfirmAStatus", targetNamespace = "http://aaans/2012/")
    ConfirmAStatus parameters
);
.... ConfirmBStatusResponse ...

I have inherited the WSDL file and I don't have any experience using WSDL files so please let me know which parts would be helpful. This is the operation in the wsdl file:

<wsdl:operation name="ConfirmAStatus">
  <wsdl:input wsaw:Action="http://aaans/2012/nsv1/ConfirmAStatus" message="tns:Service_ConfirmAStatus_InputMessage"/>
  <wsdl:output wsaw:Action="http://aaans/2012/nsv1/ConfirmAStatusResponse" message="tns:Service_ConfirmAStatus_OutputMessage"/>
</wsdl:operation>

I am quite at a loss understanding the error message. The parameter type of the function is clearly of type ConfirmAStatus and not ...StatusResponse as claimed in the error message. I tried adding default operation namespace as mentioned in the other SO post but to no avail. I don't even know if it has anything to do with namespaces. If anyone has a pointer in which direction I could try to solve this I would be very thankful.

edit: adding wsdl:message part

<wsdl:message name="Service_ConfirmAStatus_InputMessage">
  <wsdl:part name="parameters" element="q1:ConfirmAStatus" xmlns:q1="hhttp://aaans/2012/"/>
</wsdl:message>
<wsdl:message name="Service_ConfirmAStatus_OutputMessage">
  <wsdl:part name="parameters" element="q2:ConfirmAStatusResponse" xmlns:q2="http://aaans/2012/"/>
</wsdl:message>

Solution

  • The error message says that the argument parameters is of type ConfirmAStatus, but should be of type ConfirmAStatusResponse

    Since your implementation expects the type ConfirmAStatus

    ConfirmAStatus parameters
    

    I suspect that the definition of the input message in the WSDL is wrong, but that part is not contained in your question.

    You probably have a message definition like this

    <wsdl:message name="Service_ConfirmAStatus_InputMessage">
        <wsdl:part name="NameOfTheElement" element="ReferenceToTheSchemaElementThatRepresentsThisMessagePart"/>
    </wsdl:message>
    

    In this example the XML schema definition of ReferenceToTheSchemaElementThatRepresentsThisMessagePart seems to be of type ConfirmAStatus instead of ConfirmAStatusResponse