Search in sources :

Example 36 with MessageInfo

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

the class WrapperClassGenerator method generate.

public Set<Class<?>> generate() {
    for (OperationInfo opInfo : interfaceInfo.getOperations()) {
        if (opInfo.isUnwrappedCapable()) {
            Method method = (Method) opInfo.getProperty(ReflectionServiceFactoryBean.METHOD);
            if (method == null) {
                continue;
            }
            MessagePartInfo inf = opInfo.getInput().getFirstMessagePart();
            if (inf.getTypeClass() == null) {
                MessageInfo messageInfo = opInfo.getUnwrappedOperation().getInput();
                createWrapperClass(inf, messageInfo, opInfo, method, true);
            }
            MessageInfo messageInfo = opInfo.getUnwrappedOperation().getOutput();
            if (messageInfo != null) {
                inf = opInfo.getOutput().getFirstMessagePart();
                if (inf.getTypeClass() == null) {
                    createWrapperClass(inf, messageInfo, opInfo, method, false);
                }
            }
        }
    }
    return wrapperBeans;
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) Method(java.lang.reflect.Method) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo)

Example 37 with MessageInfo

use of org.apache.cxf.service.model.MessageInfo in project steve by RWTH-i5-IDSG.

the class FromAddressInterceptor method getChargeBoxId.

private String getChargeBoxId(Message message) {
    MessageContentsList lst = MessageContentsList.getContentsList(message);
    if (lst == null) {
        return null;
    }
    MessageInfo mi = (MessageInfo) message.get("org.apache.cxf.service.model.MessageInfo");
    for (MessagePartInfo mpi : mi.getMessageParts()) {
        if (CHARGEBOX_ID_HEADER.equals(mpi.getName().getLocalPart())) {
            return (String) lst.get(mpi);
        }
    }
    return null;
}
Also used : MessageContentsList(org.apache.cxf.message.MessageContentsList) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo)

Example 38 with MessageInfo

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

the class AbstractInDatabindingInterceptor method getMessageInfo.

protected MessageInfo getMessageInfo(Message message, BindingOperationInfo operation, boolean requestor) {
    MessageInfo msgInfo;
    OperationInfo intfOp = operation.getOperationInfo();
    if (requestor) {
        msgInfo = intfOp.getOutput();
        message.put(MessageInfo.class, intfOp.getOutput());
    } else {
        msgInfo = intfOp.getInput();
        message.put(MessageInfo.class, intfOp.getInput());
    }
    return msgInfo;
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo)

Example 39 with MessageInfo

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

the class SoapBindingFactory method initializeMessage.

private void initializeMessage(SoapBindingInfo bi, BindingOperationInfo boi, BindingMessageInfo bmsg) {
    MessageInfo msg = bmsg.getMessageInfo();
    List<MessagePartInfo> messageParts = new ArrayList<>();
    messageParts.addAll(msg.getMessageParts());
    List<SoapHeader> headers = SOAPBindingUtil.getSoapHeaders(bmsg.getExtensors(ExtensibilityElement.class));
    if (headers != null) {
        for (SoapHeader header : headers) {
            SoapHeaderInfo headerInfo = new SoapHeaderInfo();
            headerInfo.setUse(header.getUse());
            if (StringUtils.isEmpty(header.getPart())) {
                throw new RuntimeException("Problem with WSDL: soap:header element in operation " + boi.getName().getLocalPart() + " does not specify a part.");
            }
            MessagePartInfo part = msg.getMessagePart(new QName(msg.getName().getNamespaceURI(), header.getPart()));
            if (part != null && header.getMessage() != null && !part.getMessageInfo().getName().equals(header.getMessage())) {
                part = null;
                // out of band, let's find it
                for (MessagePartInfo mpi : msg.getOutOfBandParts()) {
                    if (mpi.getName().getLocalPart().equals(header.getPart()) && mpi.getMessageInfo().getName().equals(header.getMessage())) {
                        part = mpi;
                    }
                }
            }
            if (part != null) {
                headerInfo.setPart(part);
                messageParts.remove(part);
                bmsg.addExtensor(headerInfo);
            }
        }
        // Exclude the header parts from the message part list.
        bmsg.setMessageParts(messageParts);
    }
    SoapBodyInfo bodyInfo = new SoapBodyInfo();
    SoapBody soapBody = SOAPBindingUtil.getSoapBody(bmsg.getExtensors(ExtensibilityElement.class));
    List<?> parts = null;
    if (soapBody == null) {
        MIMEMultipartRelated mmr = bmsg.getExtensor(MIMEMultipartRelated.class);
        if (mmr != null) {
            parts = mmr.getMIMEParts();
        }
    } else {
        bmsg.addExtensor(soapBody);
        bodyInfo.setUse(soapBody.getUse());
        parts = soapBody.getParts();
    }
    // Initialize the body parts.
    List<MessagePartInfo> attParts = null;
    if (parts != null) {
        List<MessagePartInfo> bodyParts = new ArrayList<>();
        for (Iterator<?> itr = parts.iterator(); itr.hasNext(); ) {
            Object part = itr.next();
            if (part instanceof MIMEPart) {
                MIMEPart mpart = (MIMEPart) part;
                attParts = handleMimePart(mpart, attParts, msg, bmsg, bodyParts, messageParts);
            } else {
                addSoapBodyPart(msg, bodyParts, (String) part);
            }
        }
        bodyInfo.setParts(bodyParts);
        bodyInfo.setAttachments(attParts);
    } else {
        bodyInfo.setParts(messageParts);
    }
    bmsg.addExtensor(bodyInfo);
}
Also used : SoapBodyInfo(org.apache.cxf.binding.soap.model.SoapBodyInfo) QName(javax.xml.namespace.QName) SoapHeaderInfo(org.apache.cxf.binding.soap.model.SoapHeaderInfo) ArrayList(java.util.ArrayList) SoapBody(org.apache.cxf.binding.soap.wsdl.extensions.SoapBody) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) MIMEMultipartRelated(javax.wsdl.extensions.mime.MIMEMultipartRelated) MessageInfo(org.apache.cxf.service.model.MessageInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) SoapHeader(org.apache.cxf.binding.soap.wsdl.extensions.SoapHeader) MIMEPart(javax.wsdl.extensions.mime.MIMEPart)

Example 40 with MessageInfo

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

the class SoapBindingFactory method createBindingInfo.

public BindingInfo createBindingInfo(ServiceInfo si, String bindingid, Object conf) {
    SoapBindingConfiguration config;
    if (conf instanceof SoapBindingConfiguration) {
        config = (SoapBindingConfiguration) conf;
    } else {
        config = new SoapBindingConfiguration();
    }
    if (WSDLConstants.NS_SOAP12.equals(bindingid) || WSDLConstants.NS_SOAP12_HTTP_BINDING.equals(bindingid)) {
        config.setVersion(Soap12.getInstance());
        config.setTransportURI(WSDLConstants.NS_SOAP_HTTP_TRANSPORT);
    }
    SoapBindingInfo info = new SoapBindingInfo(si, bindingid, config.getVersion());
    info.setName(config.getBindingName(si));
    info.setStyle(config.getStyle());
    info.setTransportURI(config.getTransportURI());
    if (config.isMtomEnabled()) {
        info.setProperty(Message.MTOM_ENABLED, Boolean.TRUE);
    }
    for (OperationInfo op : si.getInterface().getOperations()) {
        SoapOperationInfo sop = new SoapOperationInfo();
        sop.setAction(config.getSoapAction(op));
        sop.setStyle(config.getStyle(op));
        BindingOperationInfo bop = info.buildOperation(op.getName(), op.getInputName(), op.getOutputName());
        bop.addExtensor(sop);
        info.addOperation(bop);
        BindingMessageInfo bInput = bop.getInput();
        if (bInput != null) {
            final MessageInfo input;
            BindingMessageInfo unwrappedMsg = bInput;
            if (bop.isUnwrappedCapable()) {
                input = bop.getOperationInfo().getUnwrappedOperation().getInput();
                unwrappedMsg = bop.getUnwrappedOperation().getInput();
            } else {
                input = bop.getOperationInfo().getInput();
            }
            setupHeaders(bop, bInput, unwrappedMsg, input, config);
        }
        BindingMessageInfo bOutput = bop.getOutput();
        if (bOutput != null) {
            final MessageInfo output;
            BindingMessageInfo unwrappedMsg = bOutput;
            if (bop.isUnwrappedCapable()) {
                output = bop.getOperationInfo().getUnwrappedOperation().getOutput();
                unwrappedMsg = bop.getUnwrappedOperation().getOutput();
            } else {
                output = bop.getOperationInfo().getOutput();
            }
            setupHeaders(bop, bOutput, unwrappedMsg, output, config);
        }
    }
    try {
        createSoapBinding(info);
    } catch (WSDLException e) {
        e.printStackTrace();
    }
    return info;
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) WSDLException(javax.wsdl.WSDLException) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo)

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