Search in sources :

Example 1 with BindingMessageInfo

use of org.apache.cxf.service.model.BindingMessageInfo in project camel by apache.

the class CxfProducer method checkParameterSize.

private void checkParameterSize(CxfEndpoint endpoint, Exchange exchange, Object[] parameters) {
    BindingOperationInfo boi = getBindingOperationInfo(exchange);
    if (boi == null) {
        throw new RuntimeCamelException("Can't find the binding operation information from camel exchange");
    }
    if (!endpoint.isWrapped()) {
        if (boi.isUnwrappedCapable()) {
            boi = boi.getUnwrappedOperation();
        }
    }
    int experctMessagePartsSize = boi.getInput().getMessageParts().size();
    if (parameters.length < experctMessagePartsSize) {
        throw new IllegalArgumentException("Get the wrong parameter size to invoke the out service, Expect size " + experctMessagePartsSize + ", Parameter size " + parameters.length + ". Please check if the message body matches the CXFEndpoint POJO Dataformat request.");
    }
    if (parameters.length > experctMessagePartsSize) {
        // need to check the holder parameters        
        int holdersSize = 0;
        for (Object parameter : parameters) {
            if (parameter instanceof Holder) {
                holdersSize++;
            }
        }
        // need to check the soap header information
        int soapHeadersSize = 0;
        BindingMessageInfo bmi = boi.getInput();
        if (bmi != null) {
            List<SoapHeaderInfo> headers = bmi.getExtensors(SoapHeaderInfo.class);
            if (headers != null) {
                soapHeadersSize = headers.size();
            }
        }
        if (holdersSize + experctMessagePartsSize + soapHeadersSize < parameters.length) {
            throw new IllegalArgumentException("Get the wrong parameter size to invoke the out service, Expect size " + (experctMessagePartsSize + holdersSize + soapHeadersSize) + ", Parameter size " + parameters.length + ". Please check if the message body matches the CXFEndpoint POJO Dataformat request.");
        }
    }
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) Holder(javax.xml.ws.Holder) SoapHeaderInfo(org.apache.cxf.binding.soap.model.SoapHeaderInfo) RuntimeCamelException(org.apache.camel.RuntimeCamelException)

Aggregations

Holder (javax.xml.ws.Holder)1 RuntimeCamelException (org.apache.camel.RuntimeCamelException)1 SoapHeaderInfo (org.apache.cxf.binding.soap.model.SoapHeaderInfo)1 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)1 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)1