Search in sources :

Example 1 with JAXWSParameter

use of org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSParameter in project cxf by apache.

the class ParameterProcessor method processInput.

private void processInput(JavaMethod method, MessageInfo inputMessage) throws ToolException {
    if (requireOutOfBandHeader()) {
        try {
            Class.forName("org.apache.cxf.binding.soap.SoapBindingFactory");
        } catch (Exception e) {
            LOG.log(Level.WARNING, new Message("SOAP_MISSING", LOG).toString());
        }
    }
    JAXWSBinding mBinding = inputMessage.getOperation().getExtensor(JAXWSBinding.class);
    for (MessagePartInfo part : inputMessage.getMessageParts()) {
        if (isOutOfBandHeader(part) && !requireOutOfBandHeader()) {
            continue;
        }
        JavaParameter param = getParameterFromPart(method, part, JavaType.Style.IN);
        if (mBinding != null && mBinding.getJaxwsParas() != null) {
            for (JAXWSParameter jwp : mBinding.getJaxwsParas()) {
                if (part.getName().getLocalPart().equals(jwp.getPart())) {
                    param.setName(jwp.getName());
                }
            }
        }
        addParameter(part, method, param);
    }
}
Also used : Message(org.apache.cxf.common.i18n.Message) JAXWSParameter(org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSParameter) JavaParameter(org.apache.cxf.tools.common.model.JavaParameter) JAXWSBinding(org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) ToolException(org.apache.cxf.tools.common.ToolException)

Example 2 with JAXWSParameter

use of org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSParameter in project cxf by apache.

the class WrapperStyleNameCollisionValidator method mapElementName.

private String mapElementName(OperationInfo op, MessageInfo mi, WrapperElement element) {
    MessagePartInfo mpi = mi.getMessagePart(element.getElementName());
    JAXWSBinding bind = op.getExtensor(JAXWSBinding.class);
    if (bind != null && bind.getJaxwsParas() != null) {
        for (JAXWSParameter par : bind.getJaxwsParas()) {
            if (mi.getName().getLocalPart().equals(par.getMessageName()) && mpi.getName().getLocalPart().equals(par.getElementName().getLocalPart())) {
                return par.getName();
            }
        }
    }
    return mpi.getElementQName().getLocalPart();
}
Also used : JAXWSParameter(org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSParameter) JAXWSBinding(org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo)

Example 3 with JAXWSParameter

use of org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSParameter in project cxf by apache.

the class ParameterProcessor method processOutput.

private void processOutput(JavaMethod method, MessageInfo inputMessage, MessageInfo outputMessage) throws ToolException {
    Map<QName, MessagePartInfo> inputPartsMap = inputMessage.getMessagePartsMap();
    List<MessagePartInfo> outputParts = outputMessage == null ? new ArrayList<>() : outputMessage.getMessageParts();
    // figure out output parts that are not present in input parts
    List<MessagePartInfo> outParts = new ArrayList<>();
    int numHeader = 0;
    if (isRequestResponse(method)) {
        for (MessagePartInfo outpart : outputParts) {
            boolean oob = false;
            if (isOutOfBandHeader(outpart)) {
                if (!requireOutOfBandHeader()) {
                    continue;
                }
                oob = true;
            }
            MessagePartInfo inpart = inputPartsMap.get(outpart.getName());
            if (inpart == null) {
                outParts.add(outpart);
                if (oob) {
                    numHeader++;
                }
                continue;
            } else if (isSamePart(inpart, outpart)) {
                boolean found = false;
                for (JavaParameter p : method.getParameters()) {
                    if (p.getQName().equals(ProcessorUtil.getElementName(outpart)) && p.getPartName().equals(outpart.getName().getLocalPart())) {
                        p.setHolder(true);
                        p.setHolderName(javax.xml.ws.Holder.class.getName());
                        String holderClass = p.getClassName();
                        if (JAXBUtils.holderClass(holderClass) != null) {
                            holderClass = JAXBUtils.holderClass(holderClass).getName();
                        }
                        p.setClassName(holderClass);
                        p.getAnnotations().clear();
                        p.setStyle(JavaType.Style.INOUT);
                        p.annotate(new WebParamAnnotator(isOutOfBandHeader(outpart)));
                        found = true;
                    }
                }
                if (!found) {
                    addParameter(outpart, method, getParameterFromPart(method, outpart, JavaType.Style.INOUT));
                }
                continue;
            } else if (!isSamePart(inpart, outpart)) {
                if (oob) {
                    numHeader++;
                }
                outParts.add(outpart);
                continue;
            }
        }
    }
    if (isRequestResponse(method)) {
        if (outParts.size() - numHeader == 1 && !isHeader(outParts.get(0))) {
            processReturn(method, outParts.get(0));
            outParts.remove(0);
        } else {
            processReturn(method, null);
        }
        JAXWSBinding mBinding = outputMessage.getOperation().getExtensor(JAXWSBinding.class);
        for (MessagePartInfo part : outParts) {
            JavaParameter param = getParameterFromPart(method, part, JavaType.Style.OUT);
            if (mBinding != null && mBinding.getJaxwsParas() != null) {
                for (JAXWSParameter jwp : mBinding.getJaxwsParas()) {
                    if (part.getName().getLocalPart().equals(jwp.getPart())) {
                        param.setName(jwp.getName());
                    }
                }
            }
            addParameter(part, method, param);
        }
    } else {
        processReturn(method, null);
    }
}
Also used : QName(javax.xml.namespace.QName) JAXWSParameter(org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSParameter) ArrayList(java.util.ArrayList) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) WebParamAnnotator(org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.annotator.WebParamAnnotator) JavaParameter(org.apache.cxf.tools.common.model.JavaParameter) JAXWSBinding(org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding)

Aggregations

MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)3 JAXWSBinding (org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding)3 JAXWSParameter (org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSParameter)3 JavaParameter (org.apache.cxf.tools.common.model.JavaParameter)2 ArrayList (java.util.ArrayList)1 QName (javax.xml.namespace.QName)1 Message (org.apache.cxf.common.i18n.Message)1 ToolException (org.apache.cxf.tools.common.ToolException)1 WebParamAnnotator (org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.annotator.WebParamAnnotator)1