ClassCastException when retring soap attachment-image

Hi
When i try to retrive my gif(picture) attachment server firs an
exception message -exception fires exception is
java.lang.ClassCastException: sun.awt.windows.WImage
with out retriving .
How do i over come this??
pLEASE post me the code how do i retrive the image
if (attachment.getContentType().equals("image/gif")) {
p2.println("inside image gif");
try{
ByteArrayInputStream contentStream = (ByteArrayInputStream)attachment.getContent();
     int bytesToRead = contentStream.available();
byte[] buffer = new byte[bytesToRead];
contentStream.read(buffer);
// write buffer to new file
     FileOutputStream file = new FileOutputStream("C:/form.gif");
     file.write(buffer);
     file.close();
p2.println("Finish retriving");
}catch(Exception e){
p2.println("exception fires");
This My client part
DataSource source = new FileDataSource("E:/img1.GIF");
DataHandler handler = new DataHandler(source);
// create attachment for message
AttachmentPart attachment = msg.createAttachmentPart(handler);
// set content id (optional)
msg.addAttachmentPart(attachment);// send message
Thanks for your time and help
Priya

Can you please post how you solved your problem (if you solved it of course).

Similar Messages

  • ClassCastException when retrieving SOAP content

    I got a java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.dom4j.TextImpl
    when retrieving SOAP content.
    The code looks like:
    SOAPPart part = message.getSOAPPart();
    SOAPEnvelope envelope = part.getEnvelope();
    SOAPBody body = envelope.getBody();
    SOAPBodyElement bookElement = ( SOAPBodyElement ) body.getChildElements().next();
    SOAPElement isbnElement = ( SOAPElement ) bookElement.getChildElements().next();
    System.out.println( isbnElement.getValue() );
    The SOAP message as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
    <soapenv:Body>
    <ns1:getPrice xmlns:ns1="http://www.deitel.com/BookPrie.wsdl">
    <arg0 xsi:type="xsd:string">0130895601</arg0>
    </ns1:getPrice>
    </soapenv:Body>
    </soapenv:Envelope>
    Any help?
    Thanks in advance.

    I had a similar problem and solved it. Please look at http://forum.java.sun.com/thread.jsp?forum=331&thread=268806 .

  • ClassCastException when calling SOAP adapter

    Hello,
    I created a Web service interface to an ABAP RFC
    via XI and a corresponding communication channel
    (SOAP/HTTP to a specific message interface with data
    types, message types, mappings etc. defined in the
    integration repository). Sending SOAP messages
    and receiving the correct replies works fine.
    However, when I transport the relevant objects
    from our test system to the consolidation system
    by exporting and then importing via the file system
    (all objects of the software component in the integration
    repository, all objects of the communication scenario
    in the integration directory), the
    ClassCastException given below is returned
    when sending the same SOAP messages
    to the consolidation system. Other SOAP interfaces
    work, but the one I imported does not.
    Unfortunately, the request neither shows up in
    the XmlMonitor nor in MessageMonitoring in the
    Runtime workbench, so I do not get a further
    indication what actually went wrong.
    Questions:
    - Has anyone had a similar problem or the same
      error message? If so, what was the cause?
    - Does anyone (maybe from SAP) know what exactly
      happens in the mentioned code line where the
      exception is thrown?
    - Where could I look to find further information
      about the error?
    System information:
    - SAP BASE 6.40, XI 3.0 with Service Pack 15
    Thanks + Cheers,
      Guido
    <?xml version='1.0'?>
    <!-- see the documentation -->
    <SOAP:Envelope xmlns:SOAP='http://schemas.xmlsoap.org/soap/envelope/'>
      <SOAP:Body>
        <SOAP:Fault>
          <faultcode>SOAP:Server</faultcode>
          <faultstring>Server Error</faultstring>
          <detail>
            <s:SystemError xmlns:s='http://sap.com/xi/WebService/xi2.0'>
              <context>XIAdapter</context>
              <code>ClassCastException</code>
              <text><![CDATA[
    java.lang.ClassCastException
         at com.sap.aii.af.mp.ejb.ModuleProcessorBean.process(ModuleProcessorBean.java:227)
         at com.sap.aii.af.mp.processor.ModuleProcessorLocalLocalObjectImpl0.process(ModuleProcessorLocalLocalObjectImpl0.java:103)
         at com.sap.aii.af.mp.soap.web.MessageServlet.callModuleProcessor(MessageServlet.java:159)
         at com.sap.aii.af.mp.soap.web.MessageServlet.doPost(MessageServlet.java:383)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:95)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:160)
              ]]></text>
            </s:SystemError>
          </detail>
        </SOAP:Fault>
      </SOAP:Body>
    </SOAP:Envelope>

    Hi,
    looking to the stack trace provided by i found this
    >>at java.security.AccessController.doPrivileged(Native >>Method)
    this means that you have defined assigned users for the business service in configuration directory.
    Make sure the client is making the webservice call using that specific user.
    cheers,
    naveen

  • Mail App Hangs when trying to attach images

    My Mail App (Leopard) keeps hanging (spinning ball) forcing me to force quit whenever I try to attach an image from my Images folder, if I do it through iPhoto it's fine but trying to attach manually it hangs everytime.
    Anyone else experiencing this?

    My Mail App (Leopard) hangs when I try to send eMail from iPhoto 5.0.4. I select the images I want in iPhoto then click eMail and Leopard Mail opens a new message then I get the rainbow of death and the image is never pulled in... Mail hangs until I force quit

  • Wrong folder and files order when attaching image ...

    Hello everyone!
    Long ago I noticed a bug in PC Suite: when you attach images to MMS message in PC Suite you would get a mixture of files and folder (folder, files, then again folders, again files, and - more surprising - also files from parent directory etc.) and you cannot get them normally sorted. No need to say that it is very inconvenient..
    I am just wondering how much time would it take Nokia to eliminate this bug as it is still present in the latest version of PC Suite 7.1.30.9. (Phone - N82). Or maybe there is some solution?..
    Thanks.

    Are you using the classic or newer version of Yahoo Mail!? I just tried adding an attachment in an email to myself & none of the pictures I used were grayed out. I am using the newer version of Yahoo Mail!
    Have you tried restarting your computer?

  • When I attach images to an email they show as the image and not an icon.  Is there a way to make the attachment an icon?

    When I attach images to an email they show as an image and not an icon.  Is there a way to have them attached as an icon?
    When I send attachments this way some people can't save them.   They can see them but not save them.
    Any ideas?

    They are received as attachments, i.e. icons. What you see is the real image on your disk, and only if small enough to be displayed. Otherwise, they are small icons inserted in the text.
    Additionally, when you place an image in the message, you will find an option in the lower right corner, otherwise absent. Use it, if need be.

  • ClassCastException when using javax.xml.soap.DetailEntry

    I am using the Java Web Services development pack and I'm getting a ClassCastException when trying to use a DetailEntry object.
    My code is basically as follows:
    SOAPFault fault = responseSoapBody.getFault();
    Detail detail = fault.getDetail();
    Iterator iterator = detail.getDetailEntries();
    DetailEntry entry = (DetailEntry)iterator.next(); //exception!!
    Exception:
    java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.dom4j.TextImpl
    The object being returned from the Iterator seems to be a TextImpl. In my CLASSPATH are the jars in the lib directory under <JWSDP>\jwsdp-1_0_01\common\lib.
    Any idea why I'm getting this Exception? Is this a bug in the JWSDP, or in my code?
    Thanks...

    You post has been forwarded to the SAAJ person as it seems
    like a SAAJ exception ... u should be hearing from the
    individual soon
    asengup

  • Iphoto Images will not Load when trying to attach as a file.

    When trying to attach a Iphoto image to either gmail or facebook, I am able to access Iphoto; however, I receive a message "Loading Iphoto images" but the photos never load. This just recently occurred a few weeks ago and I have never had problems uploading photos from Iphoto in the past. I am able to drag the photo to my desktop and then upload from the desktop folder but am curious why the Iphoto images are no longer being loaded.
    Thanks ~ Marie

    Try repair permissions with Disk Utility.
    Regards
    TD

  • When replying to a message with attached images, those images are included in the reply. I don't want that.

    I received an email from a friend with two attached images with "Content-Disposition: inline". When I replied to the message to say "hey, cool," those messages were included in the quoted message and attached and sent with my reply. That really shouldn't be the default behavior, and even if someone thinks it should be, there has to be a way to turn it off, right?
    Please tell me how to turn it off.
    Google searches turn up posts by frustrated users going all the way back to 2008, and there seems to be no answer better than "manually delete the photos each time".

    OK, so if a message contains images as part of signatures, it wouldn't necessarily be correct to delete them. So we're left with doing it on a case by case basis.
    People who don't like graphic content use plain text; this would automatically dispose of inline graphics content (though not true attachments).

  • When I click attach when sending an email with an attachment I get a dropdown that says "single image" or "default multiple". I choose one. Nothing happens as far as offering a choice as to what doc or photo to attach. What do i need to do?

    When I click attach when sending an email with an attachment I get a dropdown that says "single image" or "default multiple". I choose one. Nothing happens as far as offering a choice as to what doc or photo to attach. I continue between the attach and attachment and still nothing .What do i need to do?

    Hmmm, Permissions are messed up somewhere!?
    Can you open to pic say in Preview, select All, Copy, 7 Paste into Mail?

  • Exception when trying to create a soap attachment javax.activation. Unsuppo

    I am trying to pass an object String [] as a soap attachment.
    Reading the docs, if I pass a parameter as type datahandler, it is automatically treated as an Attachment.
    I used the constructor DataHandler (Object obj, String mimeType)
    where the object was my StringArray, and MIME is the XML representation of
    a java type, which according to weblogic docs is NMTOKENS,IDREF or ENTITIES.
    It threw the same error for the other two.
    Am I using DataHandler correctly, is MIME the SOAP representation of the Java Object in memory.
    Thanks for any help
    Tony

    I am trying to pass an object String [] as a soap attachment.
    Reading the docs, if I pass a parameter as type datahandler, it is automatically treated as an Attachment.
    I used the constructor DataHandler (Object obj, String mimeType)
    where the object was my StringArray, and MIME is the XML representation of
    a java type, which according to weblogic docs is NMTOKENS,IDREF or ENTITIES.
    It threw the same error for the other two.
    Am I using DataHandler correctly, is MIME the SOAP representation of the Java Object in memory.
    Thanks for any help
    Tony

  • "Content is not allowed in prolog" with SOAP Attachment

    I'm writing an application using SAAJ that sends a soap message to a servlet which responds with some information, including HTML which the client application will display. The HTML has to go into a SOAP attachment so the tags won't get confused with XML.
    I had the whole thing working with plain text sending within a normal node, and I only switched a few lines to make that text an attachment with HTML instead, but now I'm getting the exception "Content is not allowed in prolog" on the Client side when it tries to create the envelope from the SOAPMessage.
    Code for building answering SOAPMessage with attachment (Servlet to Client)
         public static SOAPMessage buildXML(Message newMessage){
              SOAPMessage msg = null;
              try {
                   MessageFactory msgFactory = MessageFactory.newInstance();
                   msg = msgFactory.createMessage();
                   // Create an envelope in the message
                   SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();
                   msg.setProperty(SOAPMessage.WRITE_XML_DECLARATION, "true");
                   msg.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, "UTF-8");
                   //Get hold of the the body
                   SOAPBody body = envelope.getBody();
                   SOAPElement soap_message = body.addChildElement("MESSAGE");
                   if (newMessage.message_type != null){
                        SOAPElement soap_message_type = soap_message.addChildElement("MESSAGETYPE");
                        soap_message_type.addTextNode(newMessage.message_type);
                   if (newMessage.questionID != 0){
                        SOAPElement soap_questionID = soap_message.addChildElement("QUESTIONID");
                        soap_questionID.addTextNode("" + newMessage.questionID);
                   if (newMessage.username != null){
                        SOAPElement soap_username = soap_message.addChildElement("USERNAME");
                        soap_username.addTextNode(newMessage.username);
                   if (newMessage.password != null){
                        SOAPElement soap_password = soap_message.addChildElement("PASSWORD");
                        soap_password.addTextNode(newMessage.password);
                   if (newMessage.message_text != null){
                        AttachmentPart soap_message_text = msg.createAttachmentPart("<html><body>" + newMessage.message_text + "</body></html>", "text/html");
                        soap_message_text.setContentId("MESSAGETEXT");
                        msg.addAttachmentPart(soap_message_text);
                        //SOAPElement soap_message_text = soap_message.addChildElement("MESSAGETEXT");
                        //soap_message_text.addTextNode(newMessage.message_text);
                   if (newMessage.sampleString != null){
                        SOAPElement soap_password = soap_message.addChildElement("SAMPLESTRING");
                        soap_password.addTextNode(newMessage.sampleString);
                   SOAPElement tmpEl;
                   for (int i=0; i<newMessage.numArrayUsed; i++){
                        tmpEl = soap_message.addChildElement("SAMPLEINT");
                        tmpEl.addTextNode("" + newMessage.sampleInt);
                   msg.saveChanges();
              } catch (Exception e) {
                   e.printStackTrace();
              return msg;
    You can see in the area where it adds MESSAGETEXT there are two clients commented out which work. The three lines above it are what changed to make it an attachment instead.
    Code in Client for recieving reply from Servlet
    SOAPMessage reply = connection.call(soap_msg, endpoint);
    System.out.println("\nReceived reply from: " + endpoint);
    reply.writeTo(System.out);
    System.out.println("");
    reply_msg = ProcessXML.parse(reply);This is the console output:
    Edit: These forums seem to be inserting an extra > before the <?xml version="1.0" encoding="UTF-8"?> line, but it doesn't exist in the code I'm pasting
    Received reply from: http://localhost:8080/kuj/CaseStudyServlet
    ------=_Part_2_371807.1137465625031
    Content-Type: text/xml; charset=UTF-8
    <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body><MESSAGE><MESSAGETYPE>deliverquestion</MESSAGETYPE><QUESTIONID>1</QUESTIONID><USERNAME>zac</USERNAME></MESSAGE></SOAP-ENV:Body></SOAP-ENV:Envelope>
    ------=_Part_2_371807.1137465625031
    Content-Type: text/html
    Content-Id: MESSAGETEXT
    <html><body>This is an Array sort Question. You will be given 10 random integers and you must sort and return them in the order of greatest to least.</body></html>
    ------=_Part_2_371807.1137465625031--
    ERROR:  'Content is not allowed in prolog.'
    17-Jan-2006 02:40:25 com.sun.xml.messaging.saaj.soap.EnvelopeFactory createEnvelope
    SEVERE: SAAJ0511: Unable to create envelope from given source
    com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to create envelope from given source:
         at com.sun.xml.messaging.saaj.soap.EnvelopeFactory.createEnvelope(EnvelopeFactory.java:111)
         at com.sun.xml.messaging.saaj.soap.ver1_1.SOAPPart1_1Impl.createEnvelopeFromSource(SOAPPart1_1Impl.java:39)
         at com.sun.xml.messaging.saaj.soap.SOAPPartImpl.getEnvelope(SOAPPartImpl.java:98)
         at com.zacwittedesign.xml.ProcessXML.realParse(ProcessXML.java:32)
         at com.zacwittedesign.xml.ProcessXML.parse(ProcessXML.java:26)
    (snip)And this is the beginning of the code for extracting the info from the SOAPMessage on the Client side:
    private static Message realParse(SOAPMessage msg){
              Message newMessage = new Message();
              try {
                   SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();
                   SOAPBody body = envelope.getBody();
    (snip)It dies on SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();
    Does anyone know what I'm doing wrong?

    I suppose I should also include the bit where the Servlet actually SENDs the resulting SOAPMessage
    SOAPMessage msg = ProcessXML.buildXML(outMessage);
    // try to send it
    try {
         response.setContentType("text/xml");
         msg.writeTo(response.getOutputStream());

  • Unique Problem: Returning SOAP+ Attachment using a class based webservice

    Hi everyone,
    Im trying to return a Soap+ attachment response back using the following:
    attachDoc(byte[] bdoc, String sTransactionNumber,
                   String sRequestedType)
    Where byte[] is the attachment and the 2 string parameters are soap message contents.
    The attachment is attached successfully to the message and i can send a response back to the clients console using :
    message.writeTo(System.out);
    My problem is that i dont know how to return this soapmessage+attachment back to the client.
    Ive tried using the return type of the method as :
    public SOAPMessage attachDoc(byte[] bdoc, String sTransactionNumber,
                   String sRequestedType)
    but i cant return a SOAPMessage return type in axis.
    Does anyone have any clues how i should sort this out so that the client gets the SOAPMessage and attachment when the method is called ?
    Please help :S
    Thanks,

    I dunno if this is what you asked for....
    Hope this helps a bit
    You may want to check this link out
    http://www-unix.globus.org/mail_archive/discuss/2007/02/msg00037.html
    MessageContext msgContext = MessageContext.getCurrentContext();
    File file = new File("filename.txt");
    org.apache.axis.attachments.AttachmentPart replyPart=
    new org.apache.axis.attachments.AttachmentPart(new DataHandler(new
    FileDataSource(file)));
    Message rspMsg= msgContext.getResponseMessage();
    rspMsg.addAttachmentPart(replyPart);
    so ur basically adding the file to the reply message.
    The link i gave has a better description, it has the entire process of sending file to server and downloading file from server codes.

  • How can I forward an email and include the attached images?

    I sent a client an email with attahced images (I attached the images, pictures I took).  The client responded with the images attached to the response.  When I try to forward that response to a third party the attached images become place holders only, no image. 
    Shouldn't my forwarded mail include the images?  Short of re-attaching the images how can I get them included in the forwarded email?

    I tested a few I forwarded to myself and I could still forward with attachments. You might try Redirecting it (Message menu).

  • How can I manually attach images from my photo booth (imported into iPhoto) to emails? Auto function, in photo booth has my photos lying sideways?

    How can I manually attach images from my photo booth to iCloud emails?
    They are imported as 'events' into my iphoto library.
    Auto function, in photo booth has my photos lying sideways when placed in 'mail' emails?

    There are many, many ways to access your files in iPhoto:   You can use any Open / Attach / Browse dialogue. On the left there's a Media heading, your pics can be accessed there. Command-Click for selecting multiple pics.
    (Note the above illustration is not a Finder Window. It's the dialogue you get when you go File -> Open)
    You can access the Library from the New Message Window in Mail:
    There's a similar option in Outlook and many, many other apps.  If you use Apple's Mail, Entourage, AOL or Eudora you can email from within iPhoto.
    If you use a Cocoa-based Browser such as Safari, you can drag the pics from the iPhoto Window to the Attach window in the browser.
    If you want to access the files with iPhoto not running:
    For users of 10.6 and later:  You can download a free Services component from MacOSXAutomation  which will give you access to the iPhoto Library from your Services Menu.
    Using the Services Preference Pane you can even create a keyboard shortcut for it.
    For Users of 10.4 and 10.5 Create a Media Browser using Automator (takes about 10 seconds) or use this free utility Karelia iMedia Browser
    Other options include:
    Drag and Drop: Drag a photo from the iPhoto Window to the desktop, there iPhoto will make a full-sized copy of the pic.
    File -> Export: Select the files in the iPhoto Window and go File -> Export. The dialogue will give you various options, including altering the format, naming the files and changing the size. Again, producing a copy.
    Show File:  a. On iPhoto 09 and earlier:  Right- (or Control-) Click on a pic and in the resulting dialogue choose 'Show File'. A Finder window will pop open with the file already selected.    3.b.
    b: On iPhoto 11 and later: Select one of the affected photos in the iPhoto Window and go File -> Reveal in Finder -> Original. A Finder window will pop open with the file already selected.

Maybe you are looking for

  • Create a delivery note with bin locations and batch numbers

    Hello everyone, when sending this message to my b1if scenario i am receiving this error (which says nothing): Exception : DI Error: (-2010) Internal error (-2010) occurred This error only occurs when using a warehouse with bin locations. For regular

  • Remove password column in Change User Request [NWBC]

    Hi everyone, one simple UI-related question: in a change access request (template based) in NWBC, if we add one or more roles under User Access tab, the associated system/clients are listed in the User System Details tab (see the attached screenshot)

  • Layout mode....totally confused

    While I've used Logic for several years I'm a total beginner at assigning MIDI controls for live work, or indeed for anything as I've never had much need to. I am therefore finding the Layout mode utterly beyond me, as so far nothing the manual claim

  • Where can I find my iWeb folder?

    Hello! I cant find my iweb folder. I tried searching in: Mackintosh / Library / Application Support / But its not there. My Spotlight is not working properly either.. I need help! :/

  • IDVD not opening

    I have just been trying to open iDVD from iLife '08 to burn a project from iMovie 6 to DVD and it opens then shuts immediately after. I opened up Console to see what was going on and this is what it said... 2007-09-09 16:22:42.709 iDVD[4675] Can't op