You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Laurence L Leff <D-...@wiu.edu> on 2007/11/05 00:27:04 UTC

Attachment setContent throws IllegalArgumentException in client

I am trying attachments with AXIS 1.4.  I got a simple string attachment
to work fine.  However, I am trying to send other objects and
keep getting an error when I run my client.

Exception in thread "main" java.lang.IllegalArgumentException: 
IllegalArgumentException:
	at org.apache.axis.attachments.AttachmentPart.
                 setContent(AttachmentPart.java:423)
	at TEightB.main(TEightB.java:83)

Here is the relevant code from my client:

     AttachmentPart attachment = 
        new org.apache.axis.attachments.AttachmentPart();
     FileDataSource FDS = new FileDataSource("EightB.xml");
     DataHandler DH = new DataHandler(FDS);
     attachment.setContent(DH,"text/xml"); <--- ERROR HERE
     

     call.addAttachmentPart(attachment);

I also tried just putting an arbitrary object in the setContent
call but that did not work either.  The only thing I got it to accept
is a string, i. e. attachment.setContent("abc","text/plain");
____________________________________________________________________

Here is the client--so far, I just want to see if it recognizes the
attachment.  When I get that far, I will try to collect the data
from my file.

import javax.xml.parsers.*;
import org.apache.xml.serialize.*;
import org.w3c.dom.*;
import org.xml.sax.*;
import Debug.*;
import javax.xml.soap.*;
import java.util.*;
import org.apache.axis.*;
import org.apache.axis.*;
import java.awt.*;
public class eightB {
public void method (SOAPEnvelope req, SOAPEnvelope resp) {
try { 
MessageContext MC = MessageContext.getCurrentContext();
SOAPMessage M = MC.getMessage();
Debug.P("Soap message " + M);
Iterator AttachmentIterator=M.getAttachments();
AttachmentPart A=(AttachmentPart)AttachmentIterator.next();
Debug.P("Attachment Part "+ A);
Object O = A.getContent();
Debug.P("got attachment " + O);

-- code discontinued as not relevant to this problem.


Dr. Laurence Leff, Associate Professor of Computer Science, Western
Illinois University Macomb 61455, Pager 309 367 0787, Fax 309 298 2302


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org