This is a "quirk" of the MimePartSerializer. It is used to serialize InputStream, DataSource, MimeBodyPart and DataHandler. When a null value is passed in for serialization, the serializer (for some reason) chooses to serialize it as an Object. That's why you get the mismatch.
I'm going to change the code to use the type specified to the serializer when serializing a null. You can either grab the source (http://cvs.apache.org/viewcvs.cgi/*checkout*/xml-soap/java/src/org/apac he/soap/encoding/soapenc/MimePartSerializer.java?rev=HEAD&content-type=t ext/plain), compile it and use it, or wait until tomorrow and get a nightly build (http://cvs.apache.org/dist/soap/nightly/). Scott Nichol ----- Original Message ----- From: "Praveen Peddi" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, January 06, 2003 11:28 AM Subject: Re: Soap With attachments example Hi Scott, Eveyrthing seems to work fine now, except one minor problem. When there is nothing to send as argument I am passing in null and thats throwing exception. Please look at the bold lines of my code below. I am passing in the type of the argument as javax.activation.DataHandler.class, but it still takes it as Object. See the exception after the code. Look at the 6th argument of the method. It is assuming the object type as "Object" not "javax.activation.DataHandler" Vector params = new Vector(); params.addElement(new Parameter("sessionID", long.class, new Long(sessionID), null)); params.addElement(new Parameter("containerID", containerID.getClass(), new String(containerID), null)); params.addElement(new Parameter("xmlString", xmlString.getClass(), new String(xmlString), null)); DataSource ds = new ByteArrayDataSource(sourceBytes, "application/octet-stream"); DataHandler dh = new DataHandler(ds); params.addElement(new Parameter("source", javax.activation.DataHandler.class, dh, null)); // params.addElement(new Parameter("encodedSource", encodedSource.getClass(), new String(encodedSource), null)); params.addElement(new Parameter("sourceFileName", sourceFileName.getClass(), new String(sourceFileName), null)); if (thumbBytes != null && thumbFileName!=null) { ds = new ByteArrayDataSource(thumbBytes, "application/octet-stream"); dh = new DataHandler(ds); params.addElement(new Parameter("thumb", javax.activation.DataHandler.class, dh, null)); params.addElement(new Parameter("thumbFileName", thumbFileName.getClass(), new String(thumbFileName), null)); } else { params.addElement(new Parameter("thumb", javax.activation.DataHandler.class, null, null)); params.addElement(new Parameter("thumbFileName", new String().getClass(), null, null)); } Exception trace is as follows: Generated fault: Fault Code = SOAP-ENV:Server Fault String = Exception while handling service request: com.contextmedia.ip.s ession.soap.CMISOAPContentService.uploadContentObject(long,java.lang.Str ing,java .lang.String,javax.activation.DataHandler,java.lang.String,java.lang.Obj ect,java .lang.String) -- no signature match java.lang.Exception: Exception while handling service request: com.contextmedia. ip.session.soap.CMISOAPContentService.uploadContentObject(long,java.lang .String, java.lang.String,javax.activation.DataHandler,java.lang.String,java.lang .Object, java.lang.String) -- no signature match at com.contextmedia.simplex.domain.content.ContentObjectUtils.uploadCont entObjectWithAttachments(ContentObjectUtils.java:742) at com.contextmedia.simplex.ui.NewContentObjectDialog$DialogActionListen er.actionPerformed(NewContentObjectDialog.java:275) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:14 45) at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra ctButton.java:1499) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel .java:373) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:245 ) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL istener.java:211) at java.awt.Component.processMouseEvent(Component.java:3710) at java.awt.Component.processEvent(Component.java:3539) at java.awt.Container.processEvent(Container.java:1159) at java.awt.Component.dispatchEventImpl(Component.java:2588) at java.awt.Container.dispatchEventImpl(Container.java:1208) at java.awt.Component.dispatchEvent(Component.java:2492) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2446 ) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2211) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2120) at java.awt.Container.dispatchEventImpl(Container.java:1195) at java.awt.Window.dispatchEventImpl(Window.java:923) at java.awt.Component.dispatchEvent(Component.java:2492) at java.awt.EventQueue.dispatchEvent(EventQueue.java:334) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh read.java:126) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre ad.java:93) at java.awt.Dialog.show(Dialog.java:375) at java.awt.Component.show(Component.java:941) at java.awt.Component.setVisible(Component.java:898) at com.contextmedia.simplex.SimplexFrame$FrameActionListener.actionPerfo rmed(SimplexFrame.java:391) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:14 45) at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra ctButton.java:1499) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel .java:373) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:245 ) at javax.swing.AbstractButton.doClick(AbstractButton.java:274) at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseRelease d(BasicMenuItemUI.java:882) at java.awt.Component.processMouseEvent(Component.java:3710) at java.awt.Component.processEvent(Component.java:3539) at java.awt.Container.processEvent(Container.java:1159) at java.awt.Component.dispatchEventImpl(Component.java:2588) at java.awt.Container.dispatchEventImpl(Container.java:1208) at java.awt.Component.dispatchEvent(Component.java:2492) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2446 ) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2211) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2120) at java.awt.Container.dispatchEventImpl(Container.java:1195) at java.awt.Window.dispatchEventImpl(Window.java:923) at java.awt.Component.dispatchEvent(Component.java:2492) at java.awt.EventQueue.dispatchEvent(EventQueue.java:334) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh read.java:126) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre ad.java:93) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:88) at java.awt.EventDispatchThread.run(EventDispatchThread.java:80) Praveen ----- Original Message ----- From: "Scott Nichol" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, January 03, 2003 4:41 PM Subject: Re: Soap With attachments example > As a general recommendation, I encourage you to capture a stack trace > for your exceptions. Just having the exception message makes it harder > to understand the cause of most exceptions. > > This particular exception means that a ByteArrayDataSource was created > with no data array, such as passing a null for the byte array. > > Scott Nichol > > ----- Original Message ----- > From: "Praveen Peddi" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Friday, January 03, 2003 4:18 PM > Subject: Re: Soap With attachments example > > > > Yeah. It works now. Its my bad. Sorry about that. > > > > BUt I have another problem. When I execute that method, I get the > following > > exception. > > > > Caught SOAPException (SOAP-ENV:Client): No data. > > > > What does this mean? I double checked that my soap method exists in > the > > descriptor and the implementation also exists on the server side. But > the > > call doesn't reach the server at all. > > > > Praveen > > ----- Original Message ----- > > From: "Scott Nichol" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Friday, January 03, 2003 2:28 PM > > Subject: Re: Soap With attachments example > > > > > > > This sample that I created from you code works for me, i.e. it does > not > > > throw an NPE. > > > > > > Scott Nichol > > > > > > import java.io.*; > > > import java.util.*; > > > import java.net.*; > > > import org.w3c.dom.*; > > > import org.xml.sax.*; > > > import org.apache.soap.util.xml.*; > > > import org.apache.soap.util.mime.*; > > > import org.apache.soap.*; > > > import org.apache.soap.transport.*; > > > import org.apache.soap.encoding.*; > > > import org.apache.soap.encoding.soapenc.*; > > > import org.apache.soap.rpc.*; > > > import org.apache.soap.messaging.*; > > > import javax.activation.*; > > > import javax.mail.internet.*; > > > import javax.xml.parsers.*; > > > > > > public class TestAttachments { > > > public static void main(String[] args) { > > > try { > > > URL url = new URL(args[0]); > > > > > > // Build the call. > > > SOAPMappingRegistry smr = new SOAPMappingRegistry(); > > > Call call = new Call(); > > > call.setSOAPMappingRegistry(smr); > > > call.setTargetObjectURI("urn:MyServiceName"); > > > call.setMethodName("myMethodName"); > > > call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC); > > > > > > byte[] sourceBytes = new byte[0]; > > > > > > Vector params = new Vector(); > > > DataSource ds = new ByteArrayDataSource(sourceBytes, > > > "application/octet-stream"); > > > DataHandler dh = new DataHandler(ds); > > > params.addElement(new Parameter("source", > > > javax.activation.DataHandler.class, dh, null)); > > > > > > DataSource ds2 = new ByteArrayDataSource(sourceBytes, > > > "application/octet-stream"); > > > DataHandler dh2 = new DataHandler(ds); > > > params.addElement(new Parameter("thumb", > > > javax.activation.DataHandler.class, > > > dh2, null)); > > > > > > call.setParams(params); > > > > > > // Invoke the call. > > > Response resp; > > > > > > try { > > > resp = call.invoke(url, ""); > > > //System.out.println("Response is: " + resp); > > > } catch (SOAPException e) { > > > System.err.println("Caught SOAPException"); > > > e.printStackTrace(); > > > } > > > } catch (Exception e) { > > > e.printStackTrace(); > > > } > > > } > > > } > > > > > > > > > -- > > > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > > > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > > > > > > > > > -- > > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > > > > > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>