Search in sources :

Example 1 with SOAPHeader

use of javax.wsdl.extensions.soap.SOAPHeader in project cxf by apache.

the class ServiceProcessor method processMultipart.

public void processMultipart(JavaMethod jm, BindingOperationInfo operation, MIMEMultipartRelated ext, JavaType.Style style) throws ToolException {
    List<MIMEPart> mimeParts = CastUtils.cast(ext.getMIMEParts());
    for (MIMEPart mPart : mimeParts) {
        List<ExtensibilityElement> extns = CastUtils.cast(mPart.getExtensibilityElements());
        for (ExtensibilityElement extElement : extns) {
            if (extElement instanceof MIMEContent) {
                MIMEContent mimeContent = (MIMEContent) extElement;
                String mimeJavaType = getJavaTypeForMimeType(mPart);
                if (JavaType.Style.IN.equals(style)) {
                    String paramName = ProcessorUtil.mangleNameToVariableName(mimeContent.getPart());
                    JavaParameter jp = jm.getParameter(paramName);
                    if (jp == null) {
                        Message message = new Message("MIMEPART_CANNOT_MAP", LOG, mimeContent.getPart());
                        throw new ToolException(message);
                    }
                    if (!jp.getClassName().equals(mimeJavaType)) {
                        // jp.setType(mimeJavaType);
                        jp.setClassName(mimeJavaType);
                    }
                } else if (JavaType.Style.OUT.equals(style)) {
                    JavaType jp = null;
                    if (!"void".equals(jm.getReturn().getType()) && mimeContent.getPart().equals(jm.getReturn().getName())) {
                        jp = jm.getReturn();
                        jp.setClassName(mimeJavaType);
                    }
                    if (jp == null) {
                        for (JavaParameter para : jm.getParameters()) {
                            if (mimeContent.getPart().equals(para.getPartName())) {
                                jp = para;
                            }
                        }
                        if (jp != null) {
                            ((JavaParameter) jp).setClassName(mimeJavaType);
                        }
                    }
                    if (jp == null) {
                        Message message = new Message("MIMEPART_CANNOT_MAP", LOG, mimeContent.getPart());
                        throw new ToolException(message);
                    }
                }
            } else if (extElement instanceof SOAPHeader) {
                processSoapHeader(jm, operation, extElement);
            }
        }
    }
}
Also used : JavaType(org.apache.cxf.tools.common.model.JavaType) MIMEContent(javax.wsdl.extensions.mime.MIMEContent) Message(org.apache.cxf.common.i18n.Message) JavaParameter(org.apache.cxf.tools.common.model.JavaParameter) ToolException(org.apache.cxf.tools.common.ToolException) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) SOAPHeader(javax.wsdl.extensions.soap.SOAPHeader) MIMEPart(javax.wsdl.extensions.mime.MIMEPart)

Example 2 with SOAPHeader

use of javax.wsdl.extensions.soap.SOAPHeader in project cxf by apache.

the class UniqueBodyPartsValidator method isValid.

public boolean isValid() {
    Collection<Binding> bindings = CastUtils.cast(def.getAllBindings().values());
    for (Binding binding : bindings) {
        uniqueBodyPartsMap = new HashMap<>();
        List<BindingOperation> ops = CastUtils.cast(binding.getBindingOperations());
        for (BindingOperation op : ops) {
            Operation operation = op.getOperation();
            if (operation != null && operation.getInput() != null) {
                Message inMessage = operation.getInput().getMessage();
                BindingInput bin = op.getBindingInput();
                Set<String> headers = new HashSet<>();
                if (bin != null) {
                    List<ExtensibilityElement> lst = CastUtils.cast(bin.getExtensibilityElements());
                    for (ExtensibilityElement ext : lst) {
                        if (!(ext instanceof SOAPHeader)) {
                            continue;
                        }
                        SOAPHeader header = (SOAPHeader) ext;
                        if (!header.getMessage().equals(inMessage.getQName())) {
                            continue;
                        }
                        headers.add(header.getPart());
                    }
                }
                if (inMessage != null && !isUniqueBodyPart(operation.getName(), inMessage, headers, binding.getQName())) {
                    return false;
                }
            }
        }
    }
    return true;
}
Also used : Binding(javax.wsdl.Binding) Message(javax.wsdl.Message) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation) BindingInput(javax.wsdl.BindingInput) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) BindingOperation(javax.wsdl.BindingOperation) SOAPHeader(javax.wsdl.extensions.soap.SOAPHeader) HashSet(java.util.HashSet)

Aggregations

ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)2 SOAPHeader (javax.wsdl.extensions.soap.SOAPHeader)2 HashSet (java.util.HashSet)1 Binding (javax.wsdl.Binding)1 BindingInput (javax.wsdl.BindingInput)1 BindingOperation (javax.wsdl.BindingOperation)1 Message (javax.wsdl.Message)1 Operation (javax.wsdl.Operation)1 MIMEContent (javax.wsdl.extensions.mime.MIMEContent)1 MIMEPart (javax.wsdl.extensions.mime.MIMEPart)1 Message (org.apache.cxf.common.i18n.Message)1 ToolException (org.apache.cxf.tools.common.ToolException)1 JavaParameter (org.apache.cxf.tools.common.model.JavaParameter)1 JavaType (org.apache.cxf.tools.common.model.JavaType)1