Package javax.xml.soap

Examples of javax.xml.soap.MimeHeader


    // Transfer MIME headers of SOAPMessage to HTTP headers.
    MimeHeaders mimeHeaders = msg.getMimeHeaders();
    if (mimeHeaders != null) {
      for (Iterator i = mimeHeaders.getAllHeaders(); i.hasNext(); ) {
        MimeHeader mimeHeader = (MimeHeader) i.next();
        //HEADER_CONTENT_TYPE and HEADER_SOAP_ACTION are already set.
        //Let's not duplicate them.
        String headerName = mimeHeader.getName();
        if (headerName.equals(HTTPConstants.HEADER_CONTENT_TYPE)
          || headerName.equals(HTTPConstants.HEADER_SOAP_ACTION)) {
          continue;
        }
        method.addRequestHeader(mimeHeader.getName(),
          mimeHeader.getValue());
      }
    }

    // process user defined headers for information.
    Hashtable userHeaderTable =
View Full Code Here


    // Transfer MIME headers of SOAPMessage to HTTP headers.
    MimeHeaders mimeHeaders = msg.getMimeHeaders();
    if (mimeHeaders != null) {
      for (Iterator i = mimeHeaders.getAllHeaders(); i.hasNext(); ) {
        MimeHeader mimeHeader = (MimeHeader) i.next();
        //HEADER_CONTENT_TYPE and HEADER_SOAP_ACTION are already set.
        //Let's not duplicate them.
        String headerName = mimeHeader.getName();
        if (headerName.equals(HTTPConstants.HEADER_CONTENT_TYPE)
          || headerName.equals(HTTPConstants.HEADER_SOAP_ACTION)) {
          continue;
        }
        method.addRequestHeader(mimeHeader.getName(),
          mimeHeader.getValue());
      }
    }

    // process user defined headers for information.
    Hashtable userHeaderTable =
View Full Code Here

     *         AttachmentPart matches at least one of the header in the provided
     *         <code>headers</code> parameter
     */
    public boolean matches(MimeHeaders headers) {
        for (Iterator i = headers.getAllHeaders(); i.hasNext();) {
            MimeHeader hdr = (javax.xml.soap.MimeHeader)i.next();
            String values[] = mimeHeaders.getHeader(hdr.getName());
            boolean found = false;
            if (values != null) {
                for (int j = 0; j < values.length; j++) {
                    if (!hdr.getValue().equalsIgnoreCase(values[j])) {
                        continue;
                    }
                    found = true;
                    break;
                }
View Full Code Here

    public void removeAttachments(MimeHeaders headers) {
        Collection<AttachmentPart> newAttachmentParts = new ArrayList<AttachmentPart>();
        for (AttachmentPart attachmentPart : attachmentParts) {
            //Get all the headers
            for (Iterator iterator = headers.getAllHeaders(); iterator.hasNext();) {
                MimeHeader mimeHeader = (MimeHeader)iterator.next();
                String[] headerValues = attachmentPart.getMimeHeader(mimeHeader.getName());
                //if values for this header name, do not remove it
                if (headerValues.length != 0) {
                    if (!(headerValues[0].equals(mimeHeader.getValue()))) {
                        newAttachmentParts.add(attachmentPart);
                    }
                }
            }
        }
View Full Code Here

            }
        }
       
        Map<String,String> httpHeaders = null;
        for (Iterator it = request.getMimeHeaders().getAllHeaders(); it.hasNext(); ) {
            MimeHeader header = (MimeHeader)it.next();
            String name = header.getName().toLowerCase();
            if (name.equals("soapaction")) {
                requestMsgCtx.setSoapAction(header.getValue());
            } else if (name.equals("content-type")) {
                // Don't set the Content-Type explicitly since it will be computed by the
                // message builder.
            } else {
                if (httpHeaders == null) {
                    httpHeaders = new HashMap<String,String>();
                }
                httpHeaders.put(header.getName(), header.getValue());
            }
        }
        if (httpHeaders != null) {
            requestMsgCtx.setProperty(HTTPConstants.HTTP_HEADERS, httpHeaders);
        }
View Full Code Here

            MimeHeaders mimeHeaders = message.getMimeHeaders();
            HashMap map = new HashMap();
            Iterator iterator = mimeHeaders.getAllHeaders();
            while (iterator.hasNext()) {
                MimeHeader mimeHeader = (MimeHeader)iterator.next();
                String key = mimeHeader.getName();
                String value = mimeHeader.getValue();
                if(key != null && value != null) {
                    if(!HTTPConstants.HEADER_CONTENT_TYPE.equalsIgnoreCase(key)) {
                        map.put(key, value);
                    }
                }
View Full Code Here

     */
    public static MimeHeaders copyMimeHeaders(MimeHeaders headers) {
        MimeHeaders result = new MimeHeaders();
        Iterator iterator = headers.getAllHeaders();
        while (iterator.hasNext()) {
            MimeHeader hdr = (MimeHeader)iterator.next();
            result.addHeader(hdr.getName(), hdr.getValue());
        }
        return result;
    }
View Full Code Here

            InputStream in1 = TestUtils.getTestFile("attach.xml");

            MessageFactory factory = MessageFactory.newInstance();
            SOAPMessage message = factory.createMessage();
            AttachmentPart ap = message.createAttachmentPart();
            MimeHeader mh = null;

            //Setting Mime Header
            ap.setMimeHeader("Content-Description", "some text");

            //Setting Content Id Header
            ap.setContentId("id@abc.com");

            //Setting Content
            ap.setContent(new StreamSource(in1), "text/xml");

            //Clearing Content
            ap.clearContent();

            try {

                //Getting Content
                InputStream is = (InputStream)ap.getContent();
                fail("Error: SOAPException should have been thrown");
            } catch (SOAPException e) {
                //Error thrown.(expected)
            }

            Iterator iterator = ap.getAllMimeHeaders();
            int cnt = 0;
            boolean foundHeader1 = false;
            boolean foundHeader2 = false;
            boolean foundDefaultHeader = false;
            while (iterator.hasNext()) {
                cnt++;
                mh = (MimeHeader)iterator.next();
                String name = mh.getName();
                String value = mh.getValue();
                if (name.equals("Content-Description") && value.equals("some text")) {
                    if (!foundHeader1) {
                        foundHeader1 = true;
                        //MimeHeaders do match for header1
                    } else {
View Full Code Here

        }

        // Transfer MIME headers of SOAPMessage to HTTP headers.
        if (mimeHeaders != null) {
            for (Iterator i = mimeHeaders.getAllHeaders(); i.hasNext(); ) {
                MimeHeader mimeHeader = (MimeHeader) i.next();
                String headerName = mimeHeader.getName();
                if (headerName.equals(HTTPConstants.HEADER_CONTENT_TYPE)
                        || headerName.equals(HTTPConstants.HEADER_SOAP_ACTION)) {
                        continue;
                }
                header2.append(mimeHeader.getName())
                .append(": ")
                .append(mimeHeader.getValue())
                .append("\r\n");
            }
        }

        if (null != httpConnection) {
View Full Code Here

        /***********************************/
        if (responseMsg != null) {
            // Transfer MIME headers to HTTP headers for response message.
            MimeHeaders responseMimeHeaders = responseMsg.getMimeHeaders();
            for (Iterator i = responseMimeHeaders.getAllHeaders(); i.hasNext(); ) {
                MimeHeader responseMimeHeader = (MimeHeader) i.next();
                res.addHeader(responseMimeHeader.getName(),
                              responseMimeHeader.getValue());
            }
            // synchronize the character encoding of request and response
            String responseEncoding = (String) msgContext.getProperty(
                    SOAPMessage.CHARACTER_SET_ENCODING);
            if (responseEncoding != null) {
View Full Code Here

TOP

Related Classes of javax.xml.soap.MimeHeader

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.