public static SoapAttachment from ( Attachment attachment ) { SoapAttachment soapAttachment = new SoapAttachment ( ) ; String contentId = attachment . getContentId ( ) ; if ( contentId . startsWith ( "<" ) && contentId . endsWith ( ">" ) ) { contentId = contentId . substring ( 1 , contentId . length ( ) - 1 ) ; } soapAttachment . setContentId ( contentId ) ; soapAttachment . setContentType ( attachment . getContentType ( ) ) ; if ( attachment . getContentType ( ) . startsWith ( "text" ) ) { try { soapAttachment . setContent ( FileUtils . readToString ( attachment . getInputStream ( ) ) . trim ( ) ) ; } catch ( IOException e ) { throw new CitrusRuntimeException ( "Failed to read SOAP attachment content" , e ) ; } } else { // Binary content soapAttachment . setDataHandler ( attachment . getDataHandler ( ) ) ; } soapAttachment . setCharsetName ( Citrus . CITRUS_FILE_ENCODING ) ; return soapAttachment ; }
Static construction method from Spring mime attachment .