Package javax.xml.soap

Examples of javax.xml.soap.AttachmentPart


                        message.setAttachments(new ArrayList<Attachment>(soapMessage
                                .countAttachments()));
                    }
                    Iterator<AttachmentPart> it = CastUtils.cast(soapMessage.getAttachments());
                    while (it.hasNext()) {
                        AttachmentPart part = it.next();
                        AttachmentImpl att = new AttachmentImpl(part.getContentId());
                        try {
                            att.setDataHandler(part.getDataHandler());
                        } catch (SOAPException e) {
                            throw new Fault(e);
                        }
                        Iterator<MimeHeader> it2 = CastUtils.cast(part.getAllMimeHeaders());
                        while (it2.hasNext()) {
                            MimeHeader header = it2.next();
                            att.setHeader(header.getName(), header.getValue());
                        }
                        message.getAttachments().add(att);
View Full Code Here


        SOAPConnectionFactory conFac = SOAPConnectionFactory.newInstance();
        SOAPMessage msg = msgFac.createMessage();
       
        QName sayHi = new QName("http://apache.org/hello_world_rpclit", "sayHiWAttach");
        msg.getSOAPBody().addChildElement(soapFac.createElement(sayHi));
        AttachmentPart ap1 = msg.createAttachmentPart();
        ap1.setContent("Attachment content", "text/plain");
        msg.addAttachmentPart(ap1);
        AttachmentPart ap2 = msg.createAttachmentPart();
        ap2.setContent("Attachment content - Part 2", "text/plain");
        msg.addAttachmentPart(ap2);
        msg.saveChanges();
       
        SOAPConnection con = conFac.createConnection();
        URL endpoint = new URL("http://localhost:9008/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit1");
View Full Code Here

                            ((AttachmentDataSource)a.getDataHandler().getDataSource()).cache();
                        } catch (IOException e) {
                            throw new Fault(e);
                        }
                    }
                    AttachmentPart ap = soapMessage.createAttachmentPart(a.getDataHandler());
                    ap.setContentId(a.getId());
                    Iterator<String> i = a.getHeaderNames();
                    while (i != null && i.hasNext()) {
                        String h = i.next();
                        String val = a.getHeader(h);
                        ap.addMimeHeader(h, val);
                    }
                    soapMessage.addAttachmentPart(ap);
                }
            }
           
View Full Code Here

            // Copy the content of the first attachement to the HTTP response stream.
            boolean foundAttachement = false;

            while (!foundAttachement && iterator.hasNext()) {
                AttachmentPart part = (AttachmentPart) iterator.next();

//                    if (part.getContentId().equals(contentID)) {
                foundAttachement = true;

                InputStream inputStream = part.getDataHandler().getInputStream();

                if (inputStream == null) {
                    throw new TranscoderException(null);
                }

                OutputStream outputStream = response.getOutputStream();

                response.setContentType(part.getContentType());
                response.setContentLength(part.getSize());
                // Copy the content of input inputStream to the output inputStream.
                // The exception loggin is set to debug level
                // because of vbm 2008030721 the browser requests the map resource
                // two times in a row and aborts the firts request most of the times
View Full Code Here

                        message.setAttachments(new ArrayList<Attachment>(soapMessage
                                .countAttachments()));
                    }
                    Iterator<AttachmentPart> it = CastUtils.cast(soapMessage.getAttachments());
                    while (it.hasNext()) {
                        AttachmentPart part = it.next();
                        AttachmentImpl att = new AttachmentImpl(part.getContentId());
                        try {
                            att.setDataHandler(part.getDataHandler());
                        } catch (SOAPException e) {
                            throw new Fault(e);
                        }
                        Iterator<MimeHeader> it2 = CastUtils.cast(part.getAllMimeHeaders());
                        while (it2.hasNext()) {
                            MimeHeader header = it2.next();
                            att.setHeader(header.getName(), header.getValue());
                        }
                        message.getAttachments().add(att);
View Full Code Here

        SOAPConnectionFactory conFac = SOAPConnectionFactory.newInstance();
        SOAPMessage msg = msgFac.createMessage();
       
        QName sayHi = new QName("http://apache.org/hello_world_rpclit", "sayHiWAttach");
        msg.getSOAPBody().addChildElement(soapFac.createElement(sayHi));
        AttachmentPart ap1 = msg.createAttachmentPart();
        ap1.setContent("Attachment content", "text/plain");
        msg.addAttachmentPart(ap1);
        AttachmentPart ap2 = msg.createAttachmentPart();
        ap2.setContent("Attachment content - Part 2", "text/plain");
        msg.addAttachmentPart(ap2);
        msg.saveChanges();
       
        SOAPConnection con = conFac.createConnection();
        URL endpoint = new URL("http://localhost:" + PORT
View Full Code Here

                        message.setAttachments(new ArrayList<Attachment>(soapMessage
                                .countAttachments()));
                    }
                    Iterator<AttachmentPart> it = CastUtils.cast(soapMessage.getAttachments());
                    while (it.hasNext()) {
                        AttachmentPart part = it.next();
                        String id = AttachmentUtil.cleanContentId(part.getContentId());
                        AttachmentImpl att = new AttachmentImpl(id);
                        try {
                            att.setDataHandler(part.getDataHandler());
                        } catch (SOAPException e) {
                            throw new Fault(e);
                        }
                        Iterator<MimeHeader> it2 = CastUtils.cast(part.getAllMimeHeaders());
                        while (it2.hasNext()) {
                            MimeHeader header = it2.next();
                            att.setHeader(header.getName(), header.getValue());
                        }
                        message.getAttachments().add(att);
View Full Code Here

                        message.setAttachments(new ArrayList<Attachment>(soapMessage
                                .countAttachments()));
                    }
                    Iterator<AttachmentPart> it = CastUtils.cast(soapMessage.getAttachments());
                    while (it.hasNext()) {
                        AttachmentPart part = it.next();
                        AttachmentImpl att = new AttachmentImpl(part.getContentId());
                        try {
                            att.setDataHandler(part.getDataHandler());
                        } catch (SOAPException e) {
                            throw new Fault(e);
                        }
                        Iterator<MimeHeader> it2 = CastUtils.cast(part.getAllMimeHeaders());
                        while (it2.hasNext()) {
                            MimeHeader header = it2.next();
                            att.setHeader(header.getName(), header.getValue());
                        }
                        message.getAttachments().add(att);
View Full Code Here

        for (int i = 0; i < bytes.length; i++) {
            bytes[i] = (byte) ('a' + ('z' - 'a') * Math.random());
        }

        ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
        AttachmentPart attachment = request.createAttachmentPart();
        // Per WSI Spect, the swa content id must start with the part name
        //http://www.ws-i.org/Profiles/AttachmentsProfile-1.0.html#Value-space_of_Content-Id_Header
        attachment.setContentId("SWAMTOMTestSOAPMessage");
        attachment.addMimeHeader("FVT-source", "STR_BODY_ELEMENT_1");
        attachment.setRawContent(bais, "text/plain");
        request.addAttachmentPart(attachment);

        // invoke
        SOAPMessage reply = dispatch.invoke(request);

        // iterate over the attachments, there should only be one
        Iterator it = reply.getAttachments();
        AttachmentPart ap = null;

        // verify that the attachment is not null or empty
        if ((ap = (AttachmentPart) it.next()) == null){
            fail("Attachment is null");
        }
       

        // verify that the attachment is not null or empty
        if (it.hasNext()){
            fail("Detected more then 1 attachment");
        }

        SOAPBody sb = reply.getSOAPBody();
        if (sb.getChildElements().hasNext()) {
            fail("Message contains soap:body payload");
        }

        bytes = ap.getRawContentBytes();
        if (bytes.length == 0) {
            fail("Attachment is empty");
        }

        // verify that endpoint has been able to modify the attachment
View Full Code Here

        for (int i = 0; i < bytes.length; i++) {
            bytes[i] = (byte) ('a' + ('z' - 'a') * Math.random());
        }

        ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
        AttachmentPart attachment = request.createAttachmentPart();
        // Per WSI Spect, the swa content id must start with the part name
        //http://www.ws-i.org/Profiles/AttachmentsProfile-1.0.html#Value-space_of_Content-Id_Header
        attachment.setContentId("jpegImageRequest=SWAMTOMTestSOAPMessage");
        attachment.addMimeHeader("FVT-source", "STR_BODY_ELEMENT_1");
        attachment.setRawContent(bais, "text/plain");
        request.addAttachmentPart(attachment);

        // invoke
        SOAPMessage reply = dispatch.invoke(request);

        // iterate over the attachments, there should only be one
        Iterator it = reply.getAttachments();
        AttachmentPart ap = null;

        // verify that the attachment is not null or empty
        if ((ap = (AttachmentPart) it.next()) == null){
            fail("Attachment is null");
        }
       
        // Make sure the content id starts with the appropriate SWA name
        if (!ap.getContentId().startsWith("jpegImageResponse=")) {
            fail("Expected content id to start with jpegImageResponse");
        }

        // verify that the attachment is not null or empty
        if (it.hasNext()){
            fail("Detected more then 1 attachment");
        }

        SOAPBody sb = reply.getSOAPBody();
        if (sb.getChildElements().hasNext()) {
            fail("Message contains soap:body payload");
        }

        bytes = ap.getRawContentBytes();
        if (bytes.length == 0) {
            fail("Attachment is empty");
        }

        // verify that endpoint has been able to modify the attachment
View Full Code Here

TOP

Related Classes of javax.xml.soap.AttachmentPart

Copyright © 2018 www.massapicom. 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.