Search in sources :

Example 16 with MessageInfo

use of org.apache.cxf.service.model.MessageInfo in project cxf by apache.

the class RMEndpoint method buildSequenceAckOperationInfo.

void buildSequenceAckOperationInfo(InterfaceInfo ii, ProtocolVariation protocol) {
    RMConstants consts = protocol.getConstants();
    OperationInfo operationInfo = ii.addOperation(consts.getSequenceAckOperationName());
    MessageInfo messageInfo = operationInfo.createMessage(consts.getSequenceAckOperationName(), MessageInfo.Type.INPUT);
    operationInfo.setInput(messageInfo.getName().getLocalPart(), messageInfo);
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo)

Example 17 with MessageInfo

use of org.apache.cxf.service.model.MessageInfo in project cxf by apache.

the class RMEndpoint method buildAckRequestedOperationInfo.

void buildAckRequestedOperationInfo(InterfaceInfo ii, ProtocolVariation protocol) {
    RMConstants consts = protocol.getConstants();
    OperationInfo operationInfo = ii.addOperation(consts.getAckRequestedOperationName());
    MessageInfo messageInfo = operationInfo.createMessage(consts.getAckRequestedOperationName(), MessageInfo.Type.INPUT);
    operationInfo.setInput(messageInfo.getName().getLocalPart(), messageInfo);
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo)

Example 18 with MessageInfo

use of org.apache.cxf.service.model.MessageInfo in project cxf by apache.

the class OperationProcessor method processMethod.

void processMethod(JavaMethod method, OperationInfo operation) throws ToolException {
    if (isAsyncMethod(method)) {
        return;
    }
    MessageInfo inputMessage = operation.getInput();
    MessageInfo outputMessage = operation.getOutput();
    if (inputMessage == null) {
        LOG.log(Level.WARNING, "NO_INPUT_MESSAGE", new Object[] { operation.getName() });
        org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message("INVALID_MEP", LOG, new Object[] { operation.getName() });
        throw new ToolException(msg);
    }
    ParameterProcessor paramProcessor = new ParameterProcessor(context);
    method.clear();
    JAXWSBinding opBinding = operation.getExtensor(JAXWSBinding.class);
    JAXWSBinding ptBinding = operation.getInterface().getExtensor(JAXWSBinding.class);
    JAXWSBinding defBinding = operation.getInterface().getService().getDescription().getExtensor(JAXWSBinding.class);
    boolean enableAsync = false;
    boolean enableMime = false;
    boolean enableWrapper = method.isWrapperStyle();
    if (defBinding != null) {
        if (defBinding.isSetEnableMime()) {
            enableMime = defBinding.isEnableMime();
        }
        if (defBinding.isSetEnableAsyncMapping()) {
            enableAsync = defBinding.isEnableAsyncMapping();
        }
        if (defBinding.isSetEnableWrapperStyle()) {
            enableWrapper = defBinding.isEnableWrapperStyle();
        }
    }
    if (ptBinding != null) {
        if (ptBinding.isSetEnableMime()) {
            enableMime = ptBinding.isEnableMime();
        }
        if (ptBinding.isSetEnableAsyncMapping()) {
            enableAsync = ptBinding.isEnableAsyncMapping();
        }
        if (ptBinding.isSetEnableWrapperStyle()) {
            enableWrapper = ptBinding.isEnableWrapperStyle();
        }
    }
    if (opBinding != null) {
        if (opBinding.isSetEnableMime()) {
            enableMime = opBinding.isEnableMime();
        }
        if (opBinding.isSetEnableAsyncMapping()) {
            enableAsync = opBinding.isEnableAsyncMapping();
        }
        if (opBinding.isSetEnableWrapperStyle()) {
            enableWrapper = opBinding.isEnableWrapperStyle();
        }
    }
    enableWrapper = checkEnableWrapper(enableWrapper, method);
    enableAsync = checkEnableAsync(enableAsync, method);
    enableMime = checkEnableMime(enableMime, method);
    method.setWrapperStyle(enableWrapper && method.isWrapperStyle());
    paramProcessor.process(method, inputMessage, outputMessage, operation.getParameterOrdering());
    if (method.isWrapperStyle()) {
        setWrapper(operation);
        method.annotate(new WrapperAnnotator(wrapperRequest, wrapperResponse));
    }
    method.annotate(new WebMethodAnnotator());
    method.annotate(new WebResultAnnotator());
    if (!method.isOneWay() && enableAsync && !isAddedAsycMethod(method)) {
        addAsyncMethod(method);
    }
    if (enableMime) {
        method.setMimeEnable(true);
    }
}
Also used : MessageInfo(org.apache.cxf.service.model.MessageInfo) JAXWSBinding(org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding) ToolException(org.apache.cxf.tools.common.ToolException) WebMethodAnnotator(org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.annotator.WebMethodAnnotator) WebResultAnnotator(org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.annotator.WebResultAnnotator) WrapperAnnotator(org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.annotator.WrapperAnnotator)

Example 19 with MessageInfo

use of org.apache.cxf.service.model.MessageInfo in project cxf by apache.

the class ServiceProcessor method isNonWrappable.

private int isNonWrappable(BindingOperationInfo bop) {
    QName operationName = bop.getName();
    MessageInfo bodyMessage = null;
    QName headerMessage = null;
    boolean containParts = false;
    boolean isSameMessage = false;
    boolean allPartsHeader = false;
    int result = NO_HEADER;
    // begin process input
    if (bop.getInput() != null && bop.getInput().getExtensors(ExtensibilityElement.class) != null) {
        List<ExtensibilityElement> extensors = bop.getInput().getExtensors(ExtensibilityElement.class);
        if (extensors != null) {
            for (ExtensibilityElement ext : extensors) {
                if (SOAPBindingUtil.isSOAPBody(ext)) {
                    bodyMessage = getMessage(operationName, true);
                }
                if (SOAPBindingUtil.isSOAPHeader(ext)) {
                    SoapHeader header = SOAPBindingUtil.getSoapHeader(ext);
                    headerMessage = header.getMessage();
                    if (header.getPart().length() > 0) {
                        containParts = true;
                    }
                }
            }
        }
        if (headerMessage != null && bodyMessage != null && headerMessage.getNamespaceURI().equalsIgnoreCase(bodyMessage.getName().getNamespaceURI()) && headerMessage.getLocalPart().equalsIgnoreCase(bodyMessage.getName().getLocalPart())) {
            isSameMessage = true;
        }
        boolean isNonWrappable = isSameMessage && containParts;
        // if is nonwrapple then return
        if (isNonWrappable) {
            result = IN_HEADER;
        }
    }
    isSameMessage = false;
    containParts = false;
    // process output
    if (bop.getOutput() != null && bop.getOutput().getExtensors(ExtensibilityElement.class) != null) {
        List<ExtensibilityElement> extensors = bop.getOutput().getExtensors(ExtensibilityElement.class);
        if (extensors != null) {
            for (ExtensibilityElement ext : extensors) {
                if (SOAPBindingUtil.isSOAPBody(ext)) {
                    bodyMessage = getMessage(operationName, false);
                }
                if (SOAPBindingUtil.isSOAPHeader(ext)) {
                    SoapHeader header = SOAPBindingUtil.getSoapHeader(ext);
                    headerMessage = header.getMessage();
                    if (header.getPart().length() > 0) {
                        containParts = true;
                    }
                }
            }
        }
        if (headerMessage != null && bodyMessage != null && headerMessage.getNamespaceURI().equalsIgnoreCase(bodyMessage.getName().getNamespaceURI()) && headerMessage.getLocalPart().equalsIgnoreCase(bodyMessage.getName().getLocalPart())) {
            isSameMessage = true;
            if (bodyMessage.getMessagePartsNumber() == 1) {
                allPartsHeader = true;
            }
        }
        boolean isNonWrappable = isSameMessage && containParts;
        if (isNonWrappable && allPartsHeader) {
            result = RESULT_HEADER;
        }
        if (isNonWrappable && !allPartsHeader) {
            result = OUT_HEADER;
        }
    }
    return result;
}
Also used : QName(javax.xml.namespace.QName) SoapHeader(org.apache.cxf.binding.soap.wsdl.extensions.SoapHeader) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) MessageInfo(org.apache.cxf.service.model.MessageInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo)

Example 20 with MessageInfo

use of org.apache.cxf.service.model.MessageInfo in project cxf by apache.

the class WSActionAnnotator method annotate.

public void annotate(JavaAnnotatable ja) {
    JavaMethod method;
    if (ja instanceof JavaMethod) {
        method = (JavaMethod) ja;
    } else {
        throw new RuntimeException("Action can only annotate JavaMethod");
    }
    boolean required = false;
    JavaInterface intf = method.getInterface();
    MessageInfo inputMessage = operation.getInput();
    MessageInfo outputMessage = operation.getOutput();
    JAnnotation actionAnnotation = new JAnnotation(Action.class);
    if (inputMessage.getExtensionAttributes() != null) {
        String inputAction = getAction(inputMessage);
        if (inputAction != null) {
            actionAnnotation.addElement(new JAnnotationElement("input", inputAction));
            required = true;
        }
    }
    if (outputMessage != null && outputMessage.getExtensionAttributes() != null) {
        String outputAction = getAction(outputMessage);
        if (outputAction != null) {
            actionAnnotation.addElement(new JAnnotationElement("output", outputAction));
            required = true;
        }
    }
    if (operation.hasFaults()) {
        List<JAnnotation> faultAnnotations = new ArrayList<>();
        for (FaultInfo faultInfo : operation.getFaults()) {
            if (faultInfo.getExtensionAttributes() != null) {
                String faultAction = getAction(faultInfo);
                if (faultAction == null) {
                    continue;
                }
                JavaException exceptionClass = getExceptionClass(method, faultInfo);
                if (!StringUtils.isEmpty(exceptionClass.getPackageName()) && !exceptionClass.getPackageName().equals(intf.getPackageName())) {
                    intf.addImport(exceptionClass.getClassName());
                }
                JAnnotation faultAnnotation = new JAnnotation(FaultAction.class);
                faultAnnotation.addElement(new JAnnotationElement("className", exceptionClass));
                faultAnnotation.addElement(new JAnnotationElement("value", faultAction));
                faultAnnotations.add(faultAnnotation);
                required = true;
            }
        }
        actionAnnotation.addElement(new JAnnotationElement("fault", faultAnnotations));
    }
    if (required) {
        method.addAnnotation("Action", actionAnnotation);
    }
}
Also used : JavaInterface(org.apache.cxf.tools.common.model.JavaInterface) FaultInfo(org.apache.cxf.service.model.FaultInfo) JavaException(org.apache.cxf.tools.common.model.JavaException) JAnnotation(org.apache.cxf.tools.common.model.JAnnotation) JAnnotationElement(org.apache.cxf.tools.common.model.JAnnotationElement) ArrayList(java.util.ArrayList) JavaMethod(org.apache.cxf.tools.common.model.JavaMethod) MessageInfo(org.apache.cxf.service.model.MessageInfo)

Aggregations

MessageInfo (org.apache.cxf.service.model.MessageInfo)73 QName (javax.xml.namespace.QName)42 OperationInfo (org.apache.cxf.service.model.OperationInfo)42 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)38 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)36 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)19 SoapOperationInfo (org.apache.cxf.binding.soap.model.SoapOperationInfo)15 Test (org.junit.Test)15 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)14 Endpoint (org.apache.cxf.endpoint.Endpoint)13 Method (java.lang.reflect.Method)11 ArrayList (java.util.ArrayList)10 Service (org.apache.cxf.service.Service)9 MessageContentsList (org.apache.cxf.message.MessageContentsList)8 Fault (org.apache.cxf.interceptor.Fault)7 Exchange (org.apache.cxf.message.Exchange)7 Message (org.apache.cxf.message.Message)7 BindingInfo (org.apache.cxf.service.model.BindingInfo)7 FaultInfo (org.apache.cxf.service.model.FaultInfo)7 UnwrappedOperationInfo (org.apache.cxf.service.model.UnwrappedOperationInfo)7