Retriving .doc and .rtf files in soap attachments

Please help me
I'm using JAXM to retrive soap attachments
When i retrive txt files (.txt) it retrivs the content of the document
without any problem but when i try to retrive .doc or rtf
it gives content as
java.io.FileInputStream@587c94
(retrive attached files which are recived from client)
how do i get the content from word or rtf document
this is the way i tried to get the content
while (it.hasNext()) {
AttachmentPart ap = (AttachmentPart)it.next();
contentType = ap.getContentType();
content =(String)ap.getContent();
p.println("content---->"+content);//wrriting to text file
System.out.println("*** attachment content: " + content);
thanks nams

Here is the code I used to send and receive a PDF file as a SOAP attachment. Note that if the sender uses a DataHandler for the attachment's content, there's no need to set the MIME type explicitly because the DataHandler does it for you.
* Sender
// create the data source and data handler
DataSource source = new FileDataSource("form.pdf");
DataHandler handler = new DataHandler(source);
// create attachment for message
AttachmentPart attachment = message.createAttachmentPart(handler);
// set content id (optional)
attachment.setContentId("enrollment_form");
// add attachment to message
message.addAttachmentPart(attachment);
// send message
providerConnection.send(message);
* Recipient
public class Receiver extends JAXMServlet implements OnewayListener {
   public void onMessage(SOAPMessage message) {
      // get attachment
      Iterator it = message.getAttachments();
      AttachmentPart attachment = (AttachmentPart) it.next();
      if (attachment.getContentType().equals("application/pdf")) {
          // read contents into byte buffer
          ByteArrayInputStream contentStream =
              (ByteArrayInputStream)attachment.getContent();
          // use standard Java I/O methods to save in file
          int bytesToRead = contentStream.available();
          byte[] buffer = new byte[bytesToRead];
          contentStream.read(buffer);
          // write buffer to new file
          FileOutputStream file = new FileOutputStream("form.pdf");
          file.write(buffer);
          file.close();
          log("Attachment " + attachment.getContentId() + " with type "
              + attachment.getContentType() + " written to form.pdf");
      else {
          log("attachment content has MIME type " + attachment.getContentType()
            + ", Java type " + attachment.getContent().getClass());
}

Similar Messages

  • Can't open doc and rtf files on my nokia e61i

    hi!I am new here,i have a problem with my e61i,I can not open doc and rtf files,if someone has a clue to tell me how can i fix the problem i'll be gratefull

    I don't know if this will help but I had a similar problem that started yesterday. I have two macs.  Once can't open MS Office files from the other Mac but can open Office files on each Mac. Drove me nuts for about 2 hours today - on the phone with Apple twice and Microsoft once.  Finally found a similar post from 2007 that suggested to turn off and on file sharing by unchecking the "Share files and folders using AFP", on both computers and rebooting. That fixed it. 
    Funny thing, it was only with Office files I created since updating the software last week. Old Office files opened fine. 

  • Hyperlinks to XLS, DOC, and PDF files that are included in a .chm file work intermittently.

    SUMMARY
    Hyperlinks to XLS, DOC, and PDF files that are included in a
    .chm file (and the Baggage Files) only work intermittently. The
    only solution appears to be deleting the Temporary Internet Files.
    PROBLEM
    1. I place the XLS, DOC, or PDF file in the Windows
    sub-directory that corresponds to the RoboHelp project sub-folder
    where the topic in which I’ll place the hyperlink exists.
    2. I open the help project in RoboHelp HTML.
    3. I right-click on the project’s Baggage Files
    sub-folder that corresponds to the Windows sub-directory in which I
    placed the XLS, DOC, or PDF file (in step 1).
    4. I import the XLS, DOC, or PDF file.
    5. I open the topic in which I’m going to place the
    hyperlink in the WYSIWYG editor.
    6. I “drag and drop” the Baggage File into the
    topic (in the WYSIWYG editor) to create a link to it.
    7. I save the changes and then generate HTML (.chm) help.
    8. I open the .chm file and click the hyperlink. The XLS,
    DOC, or PDF file may or may not open.
    9. When the hyperlink works correctly, for DOC and XLS files,
    a “File Download – Security Warning” dialog box
    appears asking, “Do you want to open or save this
    file?”. The buttons that are available are
    “Open”, “Save”, and “Cancel”.
    These buttons work then as one would expect. (When the hyperlink
    works correctly for a PDF file, it simply opens the PDF file in a
    new window; there’s no prompt to save, open, or cancel.)
    10. When a hyperlink does NOT work, for DOC, XLS, and PDF
    files, no dialog box or other visual message is displayed. Instead,
    the sound that is associated with the “Exclamation”
    program event is played (the “Windows XP
    Exclamation.wav” file is the WinXP default).
    Other Notes:
    - The hyperlinks ALWAYS work when I view a topic using the
    “View Selected Item” function (Ctrl+W) in the RoboHelp
    HTML project.
    - Once a hyperlink stops working, it will not start working
    again until I delete all the Temporary Internet Files.
    - A hyperlink will stop working even if Internet Explorer
    (iexplore.exe) is closed the entire time.
    WORKAROUND
    Through trial and error, I have discovered that if a
    hyperlink stops working, I can get it to work again using the
    following steps:
    1. Leave the .chm file open.
    2. Open Internet Explorer.
    3. Click Tools>Internet Options….
    4. From the “Internet Options” dialog box, select
    the “General” tab.
    5. Under the “Temporary Internet Files” section,
    click the “Delete Files…” button.
    6. From the “Delete Files” dialog box, select
    “Delete all offline content” and then click
    “OK”. The files are deleted and the “Delete
    Files” dialog box closes.
    7. Click “OK” to close the “Internet
    Options” dialog box.
    8. Without closing Internet Explorer and without re-starting
    the .chm file, all the hyperlinks that didn’t work before
    will now work.
    GENERAL SYSTEM INFORMATION
    - Windows XP Pro, SP2
    - Internet Explorer 6.0.2900.2180
    - RoboHelp X5, 5.0.2 Build 801
    - HTML (.chm) help project files exist on my local machine
    - HTML (.chm) help file is run from my local machine
    - Project is under RoboSource version control
    TEMPORARY INTERNET SETTINGS
    - “Check for newer versions of stored pages” is
    set to “Automatically”
    - “Current location” for the Temporary Internet
    files folder is set to “C:\Documents and Settings\My
    Username\Local Settings\Temporary Internet Files\”
    - “Amount of disk space to use” is set to
    “594” MB
    “View Files…”
    - An XLS or DOC file will be listed here if I click its
    hyperlink and then click either “Open” or
    “Save” from the “File Download – Security
    Warning” dialog box.
    - A file will appear here even if I click “Save”
    and then click “Cancel” from the subsequent “Save
    As” dialog box.
    - If I click “Cancel” from the “File
    Download – Security Warning” dialog box, the file does
    not appear in the Temporary Internet Files folder.
    - When a file does appear in the Temporary Internet Files
    folder, its Internet Address is displayed similar to the following:
    “ms-its:C:\PrimaryProjectFolder\ProjectName.chm::/SubFolderName/FileName.xls”
    “View Objects…”
    Here’s a list of all the program files that appear:
    - “Microsoft Office Template and Media Control”
    (Last Accessed 12/13/06) (Version 12,0,6024,0)
    - “Shockwave ActiveX Control” (Last Accessed
    12/14/06) (Version 10,1,4,20)
    - “Shockwave Flash Object” (Last Accessed
    12/18/06) (Version 9,0,28,0)
    - “Windows Genuine Advantage Validation Tool”
    (Last Accessed 12/14/06) (Version 1,5,722,0)
    - “WUWebControl Class” (Last Accessed 12/13/06)
    (Version 5,8,0,2469)
    Today is 12/18/06 so the only program file that is listed as
    having been “Last Accessed” today is the
    “Shockwave Flash Object”.
    REQUEST FOR HELP
    I really want to include certain PDF, DOC, and XLS files in
    their native format in a .chm file. However, I need a better
    solution to my problem than the one I discovered. What I really
    want is to avoid the entire problem altogether.
    Have anyone seen this before or have any suggestions?

    You wont be able to do that. The embedded objects would appear as images only.

  • Opening .doc and .docx files in Pages

    I've been trying to make pages a default application to open .doc and .docx files instead of Textedit, but couldn't find a way?
    any help?

    Select a document in the Finder, choose Get Info from the File menu, specify Pages under Open With, click on Change All, and confirm this action.
    (42061)

  • Uploading .doc and .pdf files from iPad

    Is there any such free app in App Store to upload .doc and .pdf files from my iPad mini to Internet?
    I usually upload my Resume on different job portals, but it is not possible from Safari or Chrome browsers on my iPad mini, I have to do it from my PC every time just to upload a single file. Looking for a solution to this reported issue.
    Thank you..

    There is no native ability to upload files other than photos and videos using the built in Safari browser.
    Look into iCab Mobile for file uploads to websites.  Its not free though, and I'm not aware of a free alternative at this point.
    https://itunes.apple.com/en/app/icab-mobile-web-browser/id308111628?mt=8
    You will need to transfer the file to iCab to be able to upload it though.

  • Sending and Retrieving XML files as soap attachments

    How do I send an XML file as an attachment and then retrieve it as an XML file from soap attachment.
    I am able to send it as an xml attachment but i cannot retrive it as an xml file.
    Plz help me out in this regard.
    Its kinda urgent...

    How do I send an XML file as an attachment and then retrieve it as an XML file from soap attachment.
    I am able to send it as an xml attachment but i cannot retrive it as an xml file.
    Plz help me out in this regard.
    Its kinda urgent...

  • Does anyone know of software that converts LaTex and rtf files to doc?

    Hi All:
    I edit documents for PhD candidates in economics. As these documents generally contain a lot of symbols, the authors use LaTex, which they sometimes convert to rtf. I prefer to edit using word and track changes. In fact, that's the only way I know how to do this. So I am wondering if anyone knows of software that converts LaTex and/or rtf files to doc files.
    Thanks so much,
    Lunenburger

    Bean can do this:
    http://www.bean-osx.com/Bean.html
    and I am sure that Word accepts rtf documents as well.
    There is a version of LaTex for Macs:
    http://evolve.lse.ac.uk/software/EquationEditor/
    (scroll down).

  • Opening .doc and .xls files

    AW 6.2.9
    Have been able to open most .doc and .xls attachments up till now.
    Had trouble and now can't (.doc files will open in textEdit). Reloaded AW but all that happens is that when I click on the open button the list of files disappears. I am not even told that it cannot open the file.
    iMac4,1 Intel Core Duo   Mac OS X (10.4.8)  

    My guess as to why you have been able to open these until recently is that the files you received were not saved with updated versions of Word & Excel. Until earlier this year I was able to open both PC & Mac versions with AppleWorks. PC versions were the first to not open but if I re-saved them with Office: Mac I could open them. Then, after a couple of Office: Mac updates, I can no longer open them. NeoOffice is a reasonable alternative.

  • Not able to save report output in a text file and RTF file

    I am using Oracle Developer6.0 . I am facing problem with reports. I am invoking reports from form using run_product.
    1. I could not able to save the report in text file . Whenever i try to save the report output in a text file.It gives dump and application get closed.
    2. In RTF format , it execute the query which i have given at the design time while creating a report . But while running i am passing query either through lexical parameter or passing value of where criteria user parameters. It display the output for the specified value. But when i save this report output in rtf file . It execute design time query and save that in a rtf file.
    If any body is having any idea about it . Please let me ASAP . It is very urgent for me.
    Thanks in advance

    Try the following:
    Do not generate the report to .rep file, but rename/copy the .rdf file to .rep file and execute it.

  • Hi - I have just bought my first IPAD and I need to transfer from my MAC a 'recipe file' consisting of many, doc and docx files - I have also just bought Keynote to do this but I can't seem to transfer,, does anyone have any suggestions? Thanks

    Hi - I have just bought my first IPAD [3 rd gen, no wifi] and one of the things I want it to do is to accept transfered word files
    preferably as folders from my MAC - I just bought Keynote but it doesn't seem to work. My files are all doc and docx so I think
    perhaps looking into it more I should have bought Pages instead,, but I don't want to spend more money on another app if
    possible. Does anyone have any suggestions?

    You can download a complete iPad User Guide here: http://manuals.info.apple.com/en/ipad_user_guide.pdf
    Also, Good Instructions http://www.tcgeeks.com/how-to-use-ipad-2/
    Apple - iPad - Guided Tours
    http://www.apple.com/ipad/videos/
    Watch the videos see all the amazing iPad apps in action. Learn how to use FaceTime, Mail, Safari, Videos, Maps, iBooks, App Store, and more.
    How to - Articles & User Guides & Tutorials
    http://www.iphone-mac.com/index.php/Index/howto/id/4/type/select
    iPad How-Tos  http://ipod.about.com/lr/ipad_how-tos/903396/1/
    You can download this guide to your iPad.
    iPad User Guide for iOS 5
    http://itunes.apple.com/us/book/ipad-user-guide-for-ios-5/id470308101?mt=11
     Cheers, Tom

  • Office Docs and Excel files mysteriously converting to tmp files

    I experienced this twice this month with two different customers. What happens is certain folders with excell and word docs will be moved inside other folders and the files will be gone only some random character file.tmp (
    54F81A6B.tmp) The first incident happend on a synology diskstation DS213 Shared Drive where the only fix was to reset the Diskstation and restore from backup. The second incident was on a Windows Home server share.  Both computers
    are windows 7 pro 64 with office 2013. Im starting to think this is a bug with office 2013. I scanned for viruses and none found. Where do i start to resolve this?

    Hi,
    Did the issue only occur with the Office files? Do you install some sync software?
    I recommend we try to install the Office 2013 SP1.
    Next, as far as I know, the Office temp file will display when we open it or use it. We may try to use
    Process Monitor to collect which program open/block the Office threads during you copying/pasting.
    Regards,
    George Zhao
    TechNet Community Support

  • How to find all doc and docx files ?

    In order to find all my DOC or DOCX documents I tried with Fider - ALL FILES but see no such options  to narrow down this search to only DOC or DOCX
    I tried with .doc and .docx but with bad results
    Once I have the list with my Word documents, I want to search for the word Music inside the files.
    Anyone has a suggestion?
    Also tried with Spotlight, no good either.
    I use Mac OS Lion

    In the Finder, choose Find (Command-F). In the search criteria, choose Kind - is - Other. In the Other text box type "Microsoft Word".
    If you search by extension, such as Name - Ends with - "docx", you will miss files with extension hidden.

  • Missing data when exporting to "MS Word (*.doc)" and "RTF (*.rtf)"

    Hello,
    We are using CR XI R2 SP3 in our product.  The reports that we generate (using ODBC dsn) show URLs from the database as hyper link text fields.  When we export the report to "Microsoft Word (.doc)" or "Rich Text Format (.rtf)" format, even though the export operation succeeds, the report is missing data when it encounters a URL that looks like following.  There is basically no data after that URL.
    http://www.xyz.com/kType=t;s.linkName=n;s.t()};s.ssl=(s.wd.location.protocol.toLowerCa
    And when it encounters a URL like following, MS Word complains that the file is invalid even though the export succeeds.
    https://www.xyz.com/m));if(m%3E0&m!=e)if(parseInt(c.substring(m+1,e%3C0?c.length:e))%3Cd.get
    If we export the report to pdf format, then everything works just fine.
    Any help on this will be highly appreciated.

    Hi Sumit
    Try to set the URL field with the RTF format. To do this try following:
    1. Right click the field->Format Field.
    2. Click the paragraph tab->Text Interpretation->RTF Text
    Now try to export it.
    Hope this helps.
    Regards
    Nikhil

  • Trouble opening downloaded .doc and pdf files

    I have suddenly been unable to open .doc word files or pdfs through Safari.  I download them and they move to the downloading arrow area, but when I click on them, word documents show this dialogue box:
    Safari can’t open the file.
    Safari can’t open the file “GERMAN_QUIZ-2.doc” because no available application can open it.
    PDFs open but the text is corrupted - pictures show ok but where text is, it just appears as a graduated solid black blurry line.
    I haven't changed any settings or downloaded anything odd, as far as I am aware.
    Any ideas?

    Thanks - I also removed an Adobe file and I can now open them.
    I used this method to open the pdf's and if I choose Open With Adobe then it opens.  If I open with Preview then it's corrupted as below.   Photos come out but text looks like this.
    Why has preview suddenly stopped opening these pdfs.  (It used to work).
    Thanks for your help

  • Not able to index doc and pdf file.

    Hi all
    We have configured km repository with fsdb mode on portal 7.0 sp 15  .  we are able to upload and edit  text file, doc file , pdf file , excel file . But we are able to search only text file.
    is there any configuration missing?
    Regards
    Rajendra.

    Hi,
    Check this path
    In the portal, choose System Administration - System Configuration - Knowledge Management - Content Management - Global Services.
    Choose Show Advanced Options and then URL Generator Service.
    In the Hosts parameter, enter the address of the portal server including the protocol, host name, domain, and port number.
    http://portalhost.mydomain.com:50000
    Regards
    Krishna.

Maybe you are looking for

  • Trading Partner Summary Report not getting genrated in PDF

    Hi all We are running EBS r12 on solaris 5.10 machine. Problem is there is a report called "Trading Partner Summary Report" it is getting completed successfully but when i try to c the output it says File does not begin with '%PDF-', Please help Rega

  • Limit number of rows from wildcard expansion- DRG-51030

    We use CONTEXT iindex in 11g to search on a text DB column, "Name". This is used in a UI to show autosuggest list of 25 matching names. When the end user types an 'a' we want to show a list of the first 25 names that contain an 'a'. We hit the issue

  • Strange call record and voicemail

    My daughter calls me and we talk for a bit then hang up. Moments later I get a voice mail of our conversation. In the voice mail I hear her talking to my son for a few seconds...then it recorded the ringing and I pick up and its the whole conversatio

  • ORA-27369: job of type EXECUTABLE failed with exit code: Incorrect function

    Hello, I am calling a windows bat file using dbms_scheduler and getting the following error. I have searched the forum and the internet and tried different switches and options. None of them solved my problem. Oracle Version: Oracle Database 11g Ente

  • YouTube app - Authentication Error

    I've been researching for over an hour and a half, thinking I've found the answer, only for it to fail.  I'm a bit aggravated, and this is my first post here, so forgive me if I've posted this in the wrong area. Okay... deep breath.  Here it goes. I'