Search in sources :

Example 6 with XMLBindingMessageFormat

use of org.apache.cxf.bindings.xformat.XMLBindingMessageFormat in project cxf by apache.

the class XMLFormatValidator method checkXMLFormat.

private boolean checkXMLFormat(BindingInfo binding) {
    Collection<BindingOperationInfo> bos = binding.getOperations();
    boolean result = true;
    boolean needRootNode = false;
    for (BindingOperationInfo bo : bos) {
        OperationInfo op = binding.getInterface().getOperation(bo.getName());
        needRootNode = false;
        final int inputPartsNum = op.getInput().getMessagePartsNumber();
        if (inputPartsNum == 0 || inputPartsNum > 1) {
            needRootNode = true;
        }
        if (needRootNode) {
            String path = "Binding(" + binding.getName().getLocalPart() + "):BindingOperation(" + bo.getName() + ")";
            List<XMLBindingMessageFormat> inExtensors = bo.getInput().getExtensors(XMLBindingMessageFormat.class);
            Iterator<XMLBindingMessageFormat> itIn = null;
            if (inExtensors != null) {
                itIn = inExtensors.iterator();
            }
            if (!findXMLFormatRootNode(itIn, bo, path + "-input")) {
                return false;
            }
            // Input check correct, continue to check output binding
            if (op.getOutput() != null) {
                needRootNode = false;
                final int outputPartsNum = op.getOutput().getMessagePartsNumber();
                if (outputPartsNum == 0 || outputPartsNum > 1) {
                    needRootNode = true;
                }
                if (needRootNode) {
                    List<XMLBindingMessageFormat> outExtensors = bo.getOutput().getExtensors(XMLBindingMessageFormat.class);
                    Iterator<XMLBindingMessageFormat> itOut = null;
                    if (outExtensors != null) {
                        itOut = outExtensors.iterator();
                    }
                    result = result && findXMLFormatRootNode(itOut, bo, path + "-Output");
                    if (!result) {
                        return false;
                    }
                }
            }
        }
    }
    return true;
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) XMLBindingMessageFormat(org.apache.cxf.bindings.xformat.XMLBindingMessageFormat)

Aggregations

XMLBindingMessageFormat (org.apache.cxf.bindings.xformat.XMLBindingMessageFormat)6 QName (javax.xml.namespace.QName)5 Binding (javax.wsdl.Binding)2 BindingOperation (javax.wsdl.BindingOperation)2 Service (javax.wsdl.Service)2 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)2 JAXBExtensibilityElement (org.apache.cxf.wsdl.JAXBExtensibilityElement)2 Test (org.junit.Test)2 File (java.io.File)1 BindingInput (javax.wsdl.BindingInput)1 Definition (javax.wsdl.Definition)1 Port (javax.wsdl.Port)1 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)1 HTTPAddress (javax.wsdl.extensions.http.HTTPAddress)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)1 XMLFormatBinding (org.apache.cxf.bindings.xformat.XMLFormatBinding)1 Fault (org.apache.cxf.interceptor.Fault)1 Message (org.apache.cxf.message.Message)1 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)1