javaspringapache-camelcxfcxf-client

Camel CXF Soap Client calling web service with multiple input parameters


I'm using Camel and have generated code from a WSDL using CXF. I generated a client stub and the implementation appears like this:

    SetDeviceDetailsv4 port = ss.getSetDeviceDetailsv4Port();  

    com.vodafone.gdsp.ws.SetDeviceDetailsv4_Type _setDeviceDetailsv4_parameters = null;
    com.vodafone.gdsp.ws.GdspHeader _setDeviceDetailsv4_gdspHeader = null;

    com.vodafone.gdsp.ws.SetDeviceDetailsv4Response _setDeviceDetailsv4__return = port.setDeviceDetailsv4(_setDeviceDetailsv4_parameters, _setDeviceDetailsv4_gdspHeader);

    System.out.println("setDeviceDetailsv4.result=" + _setDeviceDetailsv4__return);

As you one can see, the port takes two parameters and returns the response, which I want to delegate back to my Camel Route. What's the best way to implement this in Camel? I already have my CXF Enpoint defined, I'm just struggling with the DSL Routing part of it. Should I add a processor like what is found in this link? Apache Camel and web services

Thanks


Solution

  • I'm not sure if this is the correct way to do it but I added both of my "input" objects as a Camel Header, then I wrote a processor that grabbed what I needed and put the two objects that the service call needed as parameters.

    public void process(Exchange exchange) throws Exception {
            Message inMessage = exchange.getIn();
            gdspHeader = inMessage.getHeader(GDSP_HEADER, com.vodafone.gdsp.ws.GdspHeader.class);
            commModule = inMessage.getHeader(COMM_MODULE_HEADER, resmed.hi.ngcs.datastore.model.CommModule.class);
            SetDeviceDetailsv4_Type deviceDetails = createSetDeviceDetailsv4(commModule);
    
            List<Object> params = new ArrayList<>();
            params.add(deviceDetails);
            params.add(gdspHeader);
    
            inMessage.setBody(params);
    
        }
    `