Package com.eviware.soapui.impl.wsdl

Examples of com.eviware.soapui.impl.wsdl.HttpAttachmentPart


    return "Custom Properties";
  }

  public AttachmentEncoding getAttachmentEncoding( String partName )
  {
    HttpAttachmentPart attachmentPart = getAttachmentPart( partName );
    if( attachmentPart == null )
      return AttachmentUtils.getAttachmentEncoding( getOperation(), partName, true );
    else
      return AttachmentUtils.getAttachmentEncoding( getOperation(), attachmentPart, true );
  }
View Full Code Here


        .getRequestParts();
    if( messageParts != null )
    {
      for( Part part : messageParts.getPartList() )
      {
        HttpAttachmentPart attachmentPart = new HttpAttachmentPart( part.getName(), part.getContentTypeList() );
        attachmentPart.setType( Attachment.AttachmentType.MIME );
        result.add( attachmentPart );
      }
    }

    if( messageContent.length() > 0 )
    {
      WsdlContext wsdlContext = operation.getInterface().getWsdlContext();
      WsdlValidator validator = new WsdlValidator( wsdlContext );
      try
      {
        XmlObject[] requestDocuments = validator.getMessageParts( messageContent, operation.getName(), isResponse );

        for( XmlObject partDoc : requestDocuments )
        {
          XmlCursor cursor = partDoc.newCursor();
          while( !cursor.isEnddoc() )
          {
            if( cursor.isContainer() )
            {
              SchemaType schemaType = cursor.getObject().schemaType();
              if( schemaType != null )
              {
                String attributeText = AttachmentUtils.getXmlMimeContentType( cursor );

                // xop?
                if( SchemaUtils.isBinaryType( schemaType ) || SchemaUtils.isAnyType( schemaType ) )
                {
                  String contentId = cursor.getTextValue();
                  if( contentId.startsWith( "cid:" ) )
                  {
                    HttpAttachmentPart attachmentPart = new HttpAttachmentPart( contentId.substring( 4 ),
                        attributeText );
                    attachmentPart
                        .setType( attributeText == null && !forceMtom ? Attachment.AttachmentType.CONTENT
                            : Attachment.AttachmentType.XOP );
                    result.add( attachmentPart );
                  }
                }
                else if( AttachmentUtils.isXopInclude( schemaType ) )
                {
                  String contentId = cursor.getAttributeText( new QName( "href" ) );
                  if( contentId != null && contentId.length() > 0 )
                  {
                    HttpAttachmentPart attachmentPart = new HttpAttachmentPart( contentId, attributeText );
                    attachmentPart.setType( Attachment.AttachmentType.XOP );
                    result.add( attachmentPart );
                  }
                }
                // swaref?
                else if( AttachmentUtils.isSwaRefType( schemaType ) )
                {
                  String contentId = cursor.getTextValue();
                  if( contentId.startsWith( "cid:" ) )
                  {
                    HttpAttachmentPart attachmentPart = new HttpAttachmentPart( contentId.substring( 4 ),
                        attributeText );
                    attachmentPart.setType( Attachment.AttachmentType.SWAREF );
                    result.add( attachmentPart );
                  }
                }
              }
            }

            cursor.toNextToken();
          }
        }
      }
      catch( Exception e )
      {
        if( e instanceof NullPointerException )
          SoapUI.logError( e );
        log.warn( e.getMessage() );
      }
    }

    if( addAnonymous )
      result.add( new HttpAttachmentPart() );

    return result;
  }
View Full Code Here

        PartsConfig messageParts = isResponse ? operation.getConfig().getResponseParts() : operation.getConfig()
                .getRequestParts();
        if (messageParts != null) {
            for (Part part : messageParts.getPartList()) {
                HttpAttachmentPart attachmentPart = new HttpAttachmentPart(part.getName(), part.getContentTypeList());
                attachmentPart.setType(Attachment.AttachmentType.MIME);
                result.add(attachmentPart);
            }
        }

        if (messageContent.length() > 0) {
            WsdlContext wsdlContext = operation.getInterface().getWsdlContext();
            WsdlValidator validator = new WsdlValidator(wsdlContext);
            try {
                XmlObject[] requestDocuments = validator.getMessageParts(messageContent, operation.getName(), isResponse);

                for (XmlObject partDoc : requestDocuments) {
                    XmlCursor cursor = partDoc.newCursor();
                    while (!cursor.isEnddoc()) {
                        if (cursor.isContainer()) {
                            SchemaType schemaType = cursor.getObject().schemaType();
                            if (schemaType != null) {
                                String attributeText = AttachmentUtils.getXmlMimeContentType(cursor);

                                // xop?
                                if (SchemaUtils.isBinaryType(schemaType) || SchemaUtils.isAnyType(schemaType)) {
                                    String contentId = cursor.getTextValue();
                                    if (contentId.startsWith("cid:")) {
                                        HttpAttachmentPart attachmentPart = new HttpAttachmentPart(contentId.substring(4),
                                                attributeText);
                                        attachmentPart
                                                .setType(attributeText == null && !forceMtom ? Attachment.AttachmentType.CONTENT
                                                        : Attachment.AttachmentType.XOP);
                                        result.add(attachmentPart);
                                    }
                                } else if (AttachmentUtils.isXopInclude(schemaType)) {
                                    String contentId = cursor.getAttributeText(new QName("href"));
                                    if (contentId != null && contentId.length() > 0) {
                                        HttpAttachmentPart attachmentPart = new HttpAttachmentPart(contentId, attributeText);
                                        attachmentPart.setType(Attachment.AttachmentType.XOP);
                                        result.add(attachmentPart);
                                    }
                                }
                                // swaref?
                                else if (AttachmentUtils.isSwaRefType(schemaType)) {
                                    String contentId = cursor.getTextValue();
                                    if (contentId.startsWith("cid:")) {
                                        HttpAttachmentPart attachmentPart = new HttpAttachmentPart(contentId.substring(4),
                                                attributeText);
                                        attachmentPart.setType(Attachment.AttachmentType.SWAREF);
                                        result.add(attachmentPart);
                                    }
                                }
                            }
                        }

                        cursor.toNextToken();
                    }
                }
            } catch (Exception e) {
                if (e instanceof NullPointerException) {
                    SoapUI.logError(e);
                }
                log.warn(e.getMessage());
            }
        }

        if (addAnonymous) {
            result.add(new HttpAttachmentPart());
        }

        return result;
    }
View Full Code Here

TOP

Related Classes of com.eviware.soapui.impl.wsdl.HttpAttachmentPart

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.