3 Replies Latest reply on Nov 11, 2005 5:46 AM by thomas.diesler

    SoapMessage on JBoss 4.0.3

    fabbricadigitale

      I'm deploying an application on Jboss 4.0.3. This application constructs a SOAPMessage with an attachment using SAAJ api. The message seems to be correct, but when I do a

      SOAPConnection.call(SOAPMessage, url)

      I get the following error:

      FATAL [org.jboss.axis.Message] InvocationTargetException:
      java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
      at org.jboss.axis.Message.setup(Message.java:333)
      at org.jboss.axis.Message.(Message.java:212)
      at org.jboss.axis.client.Call.invoke(Call.java:2054)
      at org.jboss.axis.soap.SOAPConnectionImpl.call(SOAPConnectionImpl.java:125)

      ....
      ....
      Caused by: java.lang.ClassCastException: org.jboss.axis.message.SOAPEnvelopeAxisImpl
      at org.jboss.axis.attachments.AttachmentsImpl.(AttachmentsImpl.java:134)
      ... 93 more

      I noticed that there is no error If I send the message without any attachment:

      AttachmentPart att = message.createAttachmentPart(
      mimeMultipart, mimeMultipart.getContentType());
      att.setContentId("multipart-content-id");

      soapMessage.addAttachmentPart(att);




      Previously I had deployed this application on Jboss 4.0.1 and everything worked fine

      Can anyone help me?

        • 1. Re: SoapMessage on JBoss 4.0.3
          anil.saldhana

          Can you post the code that uses the SAAJ API to construct the soap message with attachments? Just the relevant portion of the code that does this will suffice. You can use the "code" button in the wiki to post the code.

          This seems to be a bug in the saaj infrastucture driven by axis in JBoss 4.0.3

          • 2. Re: SoapMessage on JBoss 4.0.3
            fabbricadigitale

            This is the portion of code.
            I need to attach a mime multipart attachment

            SOAPMessage message = messageFactory.createMessage();
            
             SOAPPart soapPart = message.getSOAPPart();
             SOAPEnvelope envelope = soapPart.getEnvelope();
             SOAPBody soapBody = envelope.getBody();
            
             SOAPElement bodyElement = soapBody.addBodyElement(BODY_ELEM_NAME);
            
             //...not relevant code
            
            
             bodyElement.addChildElement(CHILD_NAME).addTextNode("textNode");
             bodyElement.addChildElement(OTHER_CHILD_NAME).addTextNode("textNode");
            
             // ...
             // Create MimeMultipart to attach to the message
             String text = "Example ...";
             MimeMultipart multipart = new MimeMultipart();
            
             //add the text to the multipart
             MimeBodyPart textPart = new MimeBodyPart();
             textPart.setDataHandler(new DataHandler(new ByteArrayDataSource(
             "Text data", text.getBytes(), "text/plain")));
             textPart.setContentID("text1.txt");
             textPart.setHeader("Content-Type", "text/plain");
             textPart.setDisposition(MimeBodyPart.ATTACHMENT);
             textPart.setHeader("Content-Transfer-Encoding", "binary");
             textPart.setFileName("text1.txt");
             multipart.addBodyPart(textPart);
            
             // add another content
             byte[] imgContent= getImageContent(myImage);//a custom method to retrieve some contents
             MimeBodyPart imgPart = new MimeBodyPart();
             imgPart.setDataHandler(new DataHandler(new ByteArrayDataSource(
             "image data", imgContent, "image/jpg")));
             smilPart.setContentID("image.img");
             smilPart.setHeader("Content-Type", "image/jpeg");
             smilPart.setDisposition(MimeBodyPart.ATTACHMENT);
             smilPart.setHeader("Content-Transfer-Encoding", "base64");
             smilPart.setFileName("file1.jpg");
             multipart.addBodyPart(imgPart, 0);
            
             multipart.setSubType("related");
            
             AttachmentPart multipartAtt = message.createAttachmentPart(
             multipart, multipart.getContentType());
             multipartAtt.setContentId("multipart-content-id");
            
             message.addAttachmentPart(multipartAtt);
            
             message.saveChanges();
            
             printMessage(message);
            
             SOAPMessage reply = connection.call(message, address);
            


            I've deleted some portions of code not relevant


            • 3. Re: SoapMessage on JBoss 4.0.3
              thomas.diesler