Examples of MIMEContent


Examples of javax.wsdl.extensions.mime.MIMEContent

            throw new RuntimeException("MIMEPart should at least contain one element!");
        }
        String partName = null;
        for (Object content : mpart.getExtensibilityElements()) {
            if (content instanceof MIMEContent) {
                MIMEContent mc = (MIMEContent)content;
                partName = mc.getPart();

                if (attParts == null) {
                    attParts = new LinkedList<MessagePartInfo>();
                }

                if (StringUtils.isEmpty(partName)) {
                    throw new RuntimeException("Problem with WSDL: mime content element in operation "
                                               + bmsg.getBindingOperation().getName().getLocalPart()
                                               + " does not specify a part.");
                }

                MessagePartInfo mpi =
                    msg.getMessagePart(new QName(msg.getName().getNamespaceURI(),
                                                 partName));
                mpi.setProperty(Message.CONTENT_TYPE, mc.getType());
                attParts.add(mpi);
                // Attachments shouldn't be part of the body message
                bmsg.getMessageParts().remove(mpi);
            } else if (SOAPBindingUtil.isSOAPBody(content)) {
                SoapBody sb = SOAPBindingUtil.getSoapBody(content);
View Full Code Here

Examples of javax.wsdl.extensions.mime.MIMEContent

        List mimePartChildren = mimePart.getExtensibilityElements();
        Iterator mimePartChildrenIt = mimePartChildren.iterator();
        while (mimePartChildrenIt.hasNext()) {
          Object nextChild = mimePartChildrenIt.next();
          if (nextChild instanceof MIMEContent) {
            MIMEContent mimeContent = (MIMEContent) nextChild;
            if (!MIMEConstants
              .NS_URI_MIME
              .equals(
                mimePart.getElementType().getNamespaceURI()))
              throw new WSIFException(
                "A MIME part in binding operation "
                  + bindingOperation.getName()
                  + " did not have the correct namespace URI of "
                  + MIMEConstants.NS_URI_MIME
                  + ".");
            containsMimeContent = true;
            if (containsSoapBody)
              throw new WSIFException(
                "A mime:part that contains a mime:content also "
                  + "contains a soap:body. Operation="
                  + getName());

            String partName = mimeContent.getPart();
            if (partName == null || partName.length() == 0)
              throw new WSIFException(
                "No part name for a mime:content. Operation="
                  + getName());
View Full Code Here

Examples of javax.wsdl.extensions.mime.MIMEContent

        if (mPart.getExtensibilityElements().size() > 1) {
            return "javax.activation.DataHandler";
        } else {
            ExtensibilityElement extElement = (ExtensibilityElement)mPart.getExtensibilityElements().get(0);
            if (extElement instanceof MIMEContent) {
                MIMEContent mimeContent = (MIMEContent)extElement;
                if ("image/jpeg".equals(mimeContent.getType()) || "image/gif".equals(mimeContent.getType())) {
                    return "java.awt.Image";
                } else if ("text/xml".equals(mimeContent.getType())
                           || "application/xml".equals(mimeContent.getType())) {
                    return "javax.xml.transform.Source";
                else {
                    return "javax.activation.DataHandler";
                }
            }
View Full Code Here

Examples of javax.wsdl.extensions.mime.MIMEContent

            MIMEPart mPart = (MIMEPart)itParts.next();
            Iterator extns = mPart.getExtensibilityElements().iterator();
            while (extns.hasNext()) {
                ExtensibilityElement extElement = (ExtensibilityElement)extns.next();
                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) {
View Full Code Here

Examples of javax.wsdl.extensions.mime.MIMEContent

            throw new RuntimeException("MIMEPart should at least contain one element!");
        }
        String partName = null;
        for (Object content : mpart.getExtensibilityElements()) {
            if (content instanceof MIMEContent) {
                MIMEContent mc = (MIMEContent)content;
                partName = mc.getPart();

                if (attParts == null) {
                    attParts = new LinkedList<MessagePartInfo>();
                }

                if (StringUtils.isEmpty(partName)) {
                    throw new RuntimeException("Problem with WSDL: mime content element in operation "
                                               + bmsg.getBindingOperation().getName().getLocalPart()
                                               + " does not specify a part.");
                }

                MessagePartInfo mpi =
                    msg.getMessagePart(new QName(msg.getName().getNamespaceURI(),
                                                 partName));
                mpi.setProperty(Message.CONTENT_TYPE, mc.getType());
                attParts.add(mpi);
                // Attachments shouldn't be part of the body message
                bmsg.getMessageParts().remove(mpi);
            } else if (SOAPBindingUtil.isSOAPBody(content)) {
                SoapBody sb = SOAPBindingUtil.getSoapBody(content);
View Full Code Here

Examples of javax.wsdl.extensions.mime.MIMEContent

                                           final String rootUri, HttpParams params) throws UnsupportedEncodingException {
        if (log.isDebugEnabled()) log.debug("Preparing http request...");
        // convenience variables...
        BindingInput bindingInput = opBinding.getBindingInput();
        HTTPOperation httpOperation = (HTTPOperation) WsdlUtils.getOperationExtension(opBinding);
        MIMEContent content = WsdlUtils.getMimeContent(bindingInput.getExtensibilityElements());
        String contentType = content == null ? "" : content.getType();
        boolean useUrlEncoded = WsdlUtils.useUrlEncoded(bindingInput) || PostMethod.FORM_URL_ENCODED_CONTENT_TYPE.equalsIgnoreCase(contentType);
        boolean useUrlReplacement = WsdlUtils.useUrlReplacement(bindingInput);

        // the http method to be built and returned
        HttpMethod method = null;

        // the 4 elements the http method may be made of
        String relativeUri = httpOperation.getLocationURI();
        String queryPath = null;
        RequestEntity requestEntity;
        String encodedParams = null;

        // ODE supports uri template in both port and operation location.
        // so assemble the final url *before* replacement
        String completeUri = rootUri;
        if (StringUtils.isNotEmpty(relativeUri)) {
            completeUri = completeUri + (completeUri.endsWith("/") || relativeUri.startsWith("/") ? "" : "/") + relativeUri;
        }

        if (useUrlReplacement) {
            // insert part values in the url
            completeUri = new UrlReplacementTransformer().transform(completeUri, partValues);
        } else if (useUrlEncoded) {
            // encode part values
            encodedParams = new URLEncodedTransformer().transform(partValues);
        }

        // http-client api is not really neat
        // something similar to the following would save some if/else manipulations.
        // But we have to deal with it as-is.
        //
        //  method = new Method(verb);
        //  method.setRequestEnity(..)
        //  etc...
        if ("GET".equalsIgnoreCase(verb) || "DELETE".equalsIgnoreCase(verb)) {
            if ("GET".equalsIgnoreCase(verb)) {
                method = new GetMethod();
            } else if ("DELETE".equalsIgnoreCase(verb)) {
                method = new DeleteMethod();
            }
            if (useUrlEncoded) {
                queryPath = encodedParams;
            }

            // Let http-client manage the redirection
            // see org.apache.commons.httpclient.params.HttpClientParams.MAX_REDIRECTS
            // default is 100
            method.setFollowRedirects(true);
        } else if ("POST".equalsIgnoreCase(verb) || "PUT".equalsIgnoreCase(verb)) {

            if ("POST".equalsIgnoreCase(verb)) {
                method = new PostMethod();
            } else if ("PUT".equalsIgnoreCase(verb)) {
                method = new PutMethod();
            }

            // some body-building...
            if (useUrlEncoded) {
                requestEntity = new StringRequestEntity(encodedParams, PostMethod.FORM_URL_ENCODED_CONTENT_TYPE, method.getParams().getContentCharset());
            } else if (contentType.endsWith(CONTENT_TYPE_TEXT_XML)) {
                // get the part to be put in the body
                Part part = opBinding.getOperation().getInput().getMessage().getPart(content.getPart());
                Element partValue = partValues.get(part.getName());
                // if the part has an element name, we must take the first element
                if (part.getElementName() != null) {
                    partValue = DOMUtils.getFirstChildElement(partValue);
                }
View Full Code Here

Examples of javax.wsdl.extensions.mime.MIMEContent

            Operation opDef = odeMex.getOperation();
            BindingOperation opBinding = portBinding.getBindingOperation(opDef.getName(), opDef.getInput().getName(), opDef.getOutput().getName());

            // assumption is made that a response may have at most one body. HttpBindingValidator checks this.
            MIMEContent outputContent = WsdlUtils.getMimeContent(opBinding.getBindingOutput().getExtensibilityElements());
            boolean isBodyMandatory = outputContent != null && outputContent.getType().endsWith("text/xml");


            try {
                final InputStream bodyAsStream = method.getResponseBodyAsStream();
                if (isBodyMandatory && bodyAsStream == null) {
View Full Code Here

Examples of javax.wsdl.extensions.mime.MIMEContent

            throw new IllegalArgumentException(httpMsgs.msgUnsupportedHttpMethod(binding, verb));
        }


        BindingOutput output = bindingOperation.getBindingOutput();
        MIMEContent outputContent = WsdlUtils.getMimeContent(output.getExtensibilityElements());
        if (outputContent!=null && !outputContent.getType().endsWith("text/xml")) {
            throw new IllegalArgumentException(httpMsgs.msgUnsupportedContentType(binding, bindingOperation));
        }

        Map outputParts = bindingOperation.getOperation().getOutput().getMessage().getParts();
        if (outputParts.size() > 1) {
            throw new IllegalArgumentException(httpMsgs.msgOnePartOnlyForOutput(binding, bindingOperation));
        }

        BindingInput input = bindingOperation.getBindingInput();

        // multipartRelated not supported
        if (WsdlUtils.useMimeMultipartRelated(input)) {
            throw new IllegalArgumentException(httpMsgs.msgMimeMultipartRelatedUnsupported(binding, bindingOperation));
        }

        // only 2 content-types supported
        MIMEContent inputContent= WsdlUtils.getMimeContent(input.getExtensibilityElements());
        if (inputContent != null) {
            String inputContentType = inputContent.getType();
            if (!inputContentType.endsWith("text/xml") && !PostMethod.FORM_URL_ENCODED_CONTENT_TYPE.equalsIgnoreCase(inputContentType)) {
                throw new IllegalArgumentException(httpMsgs.msgUnsupportedContentType(binding, bindingOperation));
            }
            Map inputParts = bindingOperation.getOperation().getInput().getMessage().getParts();
            if (inputParts.size() > 1) {
View Full Code Here

Examples of javax.wsdl.extensions.mime.MIMEContent

                    if (mpart.getExtensibilityElements().size() < 1) {
                        throw new RuntimeException("MIMEPart should at least contain one element!");
                    }
                    for (Object content : mpart.getExtensibilityElements()) {
                        if (content instanceof MIMEContent) {
                            MIMEContent mc = (MIMEContent)content;
                            partName = mc.getPart();

                            if (attParts == null) {
                                attParts = new LinkedList<MessagePartInfo>();
                            }

                            MessagePartInfo mpi =
                                msg.getMessagePart(new QName(msg.getName().getNamespaceURI(),
                                                             partName));
                            mpi.setProperty(Message.CONTENT_TYPE, mc.getType());
                            attParts.add(mpi);
                            // Attachments shouldn't be part of the body message
                            bmsg.getMessageParts().remove(mpi);
                        } else if (SOAPBindingUtil.isSOAPBody(content)) {
                            SoapBody sb = SOAPBindingUtil.getSoapBody(content);
View Full Code Here

Examples of javax.wsdl.extensions.mime.MIMEContent

            throw new RuntimeException("MIMEPart should at least contain one element!");
        }
        String partName = null;
        for (Object content : mpart.getExtensibilityElements()) {
            if (content instanceof MIMEContent) {
                MIMEContent mc = (MIMEContent)content;
                partName = mc.getPart();

                if (attParts == null) {
                    attParts = new LinkedList<MessagePartInfo>();
                }

                if (StringUtils.isEmpty(partName)) {
                    throw new RuntimeException("Problem with WSDL: mime content element in operation "
                                               + bmsg.getBindingOperation().getName().getLocalPart()
                                               + " does not specify a part.");
                }

                MessagePartInfo mpi =
                    msg.getMessagePart(new QName(msg.getName().getNamespaceURI(),
                                                 partName));
                mpi.setProperty(Message.CONTENT_TYPE, mc.getType());
                attParts.add(mpi);
                // Attachments shouldn't be part of the body message
                bmsg.getMessageParts().remove(mpi);
            } else if (SOAPBindingUtil.isSOAPBody(content)) {
                SoapBody sb = SOAPBindingUtil.getSoapBody(content);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.