Package javax.xml.soap

Examples of javax.xml.soap.MimeHeader


            }
        }

        Iterator mimeHeaderIterator = mimeHeaders.getAllHeaders();
        while (mimeHeaderIterator.hasNext()) {
            MimeHeader mimeHeader = (MimeHeader)mimeHeaderIterator.next();
            String value = mimeHeader.getValue();
            setMimeHeader(mimeHeader.getName(), value);
        }
        soapMessage = parentSoapMsg;

        String knownEncoding = (String) soapMessage.getProperty(SOAPMessage.CHARACTER_SET_ENCODING);
        XMLStreamReader xmlReader = null;
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

      else if (log.isTraceEnabled())
      {
         Iterator<MimeHeader> itMimeHeaders = mimeHeaders.getAllHeaders();
         while (itMimeHeaders.hasNext())
         {
            MimeHeader mh = itMimeHeaders.next();
            log.trace(mh);
         }
      }

      ContentType contentType = getContentType(mimeHeaders);
View Full Code Here

      private boolean containsAllHeaders(Iterator headerIterator, AttachmentPart part)
      {
         while (headerIterator.hasNext())
         {
            MimeHeader header = (MimeHeader)headerIterator.next();
            String[] values = part.getMimeHeader(header.getName());
            if (values == null)
               return false;

            boolean match = false;
            for (int j = 0; j < values.length; j++)
            {
               if (values[j].equalsIgnoreCase(header.getValue()))
               {
                  match = true;
                  break;
               }
            }
View Full Code Here

      metadata.put("HEADER", props);

      Iterator i = mimeHeaders.getAllHeaders();
      while (i.hasNext())
      {
         MimeHeader header = (MimeHeader)i.next();
         String currentValue = props.getProperty(header.getName());

         /*
          * Coalesce multiple headers into one
          *
          * From HTTP/1.1 RFC 2616:
          *
          * Multiple message-header fields with the same field-name MAY be
          * present in a message if and only if the entire field-value for that
          * header field is defined as a comma-separated list [i.e., #(values)].
          * It MUST be possible to combine the multiple header fields into one
          * "field-name: field-value" pair, without changing the semantics of
          * the message, by appending each subsequent field-value to the first,
          * each separated by a comma.
          */
         if (currentValue != null)
         {
            props.put(header.getName(), currentValue + "," + header.getValue());
         }
         else
         {
            props.put(header.getName(), header.getValue());
         }
      }
   }
View Full Code Here

                String contentType1 = responseMessage.getContentType(soapConstants);
                res.setContentType(contentType1);
                // Transfer MIME headers to HTTP headers for response message.
                MimeHeaders responseMimeHeaders = responseMessage.getMimeHeaders();
                for (Iterator i = responseMimeHeaders.getAllHeaders(); i.hasNext();) {
                    MimeHeader responseMimeHeader = (MimeHeader) i.next();
                    res.setHeader(responseMimeHeader.getName(),
                            responseMimeHeader.getValue());
                }
                //TODO discuss this with dims.
//                // synchronize the character encoding of request and response
//                String responseEncoding = (String) messageContext.getProperty(
//                        SOAPMessage.CHARACTER_SET_ENCODING);
View Full Code Here

                        } 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

    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

            // Transfer HTTP headers to MIME headers for request message.
            MimeHeaders requestMimeHeaders = requestMsg.getMimeHeaders(  );
            for ( Iterator i = requestHeaders.getAllHeaders(  ); i.hasNext(  ); )
            {
               MimeHeader requestHeader = (MimeHeader) i.next(  );
               requestMimeHeaders.addHeader( requestHeader.getName(  ),
                                             requestHeader.getValue(  ) );
            }

            msgContext.setRequestMessage( requestMsg );

            // put character encoding of request to message context
            // in order to reuse it during the whole process.
            String requestEncoding = (String) requestMsg.getProperty( SOAPMessage.CHARACTER_SET_ENCODING );
            if ( requestEncoding != null )
            {
               msgContext.setProperty( SOAPMessage.CHARACTER_SET_ENCODING, requestEncoding );
            }

            // set up session, if any
            if ( m_server.isSessionUsed(  ) )
            {
               // did we get a cookie?
               if ( cookie.length(  ) > 0 )
               {
                  cooky = cookie.toString(  ).trim(  );
               }
               else if ( cookie2.length(  ) > 0 )
               {
                  cooky = cookie2.toString(  ).trim(  );
               }

               // if cooky is null, cook up a cooky
               if ( cooky == null )
               {
                  // fake one up!
                  // make it be an arbitrarily increasing number
                  // (no this is not thread safe because ++ isn't atomic)
                  int i = SimpleAxisServer.sessionIndex++;
                  cooky = "" + i;
               }

               msgContext.setSession( m_server.createSession( cooky ) );
            }

            // invoke the Axis engine
            engine.invoke( msgContext );

            // Retrieve the response from Axis
            responseMsg = msgContext.getResponseMessage(  );

            if ( responseMsg == null )
            {
               status = NOCONTENT;
            }
         }
         catch ( Exception e )
         {
            AxisFault af;
            if ( e instanceof AxisFault )
            {
               af = (AxisFault) e;
               log.debug( Messages.getMessage( "serverFault00" ),
                          af );
               QName faultCode = af.getFaultCode(  );
               if ( Constants.FAULT_SOAP12_SENDER.equals( faultCode ) )
               {
                  status = SENDER;
               }
               else if ( "Server.Unauthorized".equals( af.getFaultCode(  ).getLocalPart(  ) ) )
               {
                  status = UNAUTH; // SC_UNAUTHORIZED
               }
               else
               {
                  status = ISE; // SC_INTERNAL_SERVER_ERROR
               }
            }
            else
            {
               status    = ISE; // SC_INTERNAL_SERVER_ERROR
               af        = AxisFault.makeFault( e );
            }

            // There may be headers we want to preserve in the
            // response message - so if it's there, just add the
            // FaultElement to it.  Otherwise, make a new one.
            responseMsg = msgContext.getResponseMessage(  );
            if ( responseMsg == null )
            {
               responseMsg = new Message( af );
               responseMsg.setMessageContext( msgContext );
            }
            else
            {
               try
               {
                  SOAPEnvelope env = responseMsg.getSOAPEnvelope(  );
                  env.clearBody(  );
                  env.addBodyElement( new SOAPFault( (AxisFault) e ) );
               }
               catch ( AxisFault fault )
               {
                  // Should never reach here!
               }
            }
         }

         // synchronize the character encoding of request and response
         String responseEncoding = (String) msgContext.getProperty( SOAPMessage.CHARACTER_SET_ENCODING );
         if ( ( responseEncoding != null ) && ( responseMsg != null ) )
         {
            responseMsg.setProperty( SOAPMessage.CHARACTER_SET_ENCODING, responseEncoding );
         }

         // Send it on its way...
         OutputStream out = m_socket.getOutputStream(  );
         out.write( HTTP );
         out.write( status );

         if ( responseMsg != null )
         {
            if ( m_server.isSessionUsed(  ) && ( null != cooky ) && ( 0 != cooky.trim(  ).length(  ) ) )
            {
               // write cookie headers, if any
               // don't sweat efficiency *too* badly
               // optimize at will
               StringBuffer cookieOut = new StringBuffer(  );
               cookieOut.append( "\r\nSet-Cookie: " ).append( cooky ).append( "\r\nSet-Cookie2: " ).append( cooky );

               // OH, THE HUMILITY!  yes this is inefficient.
               out.write( cookieOut.toString(  ).getBytes(  ) );
            }

            //out.write(XML_MIME_STUFF);
            out.write( ( "\r\n" + HTTPConstants.HEADER_CONTENT_TYPE + ": "
                       + responseMsg.getContentType( msgContext.getSOAPConstants(  ) ) ).getBytes(  ) );

            // Writing the length causes the entire message to be decoded twice.
            //out.write(("\r\n" + HTTPConstants.HEADER_CONTENT_LENGTH + ": " + responseMsg.getContentLength()).getBytes());
            // putInt(out, response.length);
            // Transfer MIME headers to HTTP headers for response message.
            for ( Iterator i = responseMsg.getMimeHeaders(  ).getAllHeaders(  ); i.hasNext(  ); )
            {
               MimeHeader responseHeader = (MimeHeader) i.next(  );
               out.write( '\r' );
               out.write( '\n' );
               out.write( responseHeader.getName(  ).getBytes(  ) );
               out.write( headerEnder );
               out.write( responseHeader.getValue(  ).getBytes(  ) );
            }

            out.write( SEPARATOR );
            responseMsg.writeTo( out );
         }
View Full Code Here

                        } 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

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.