If you are attaching an already created zip file, create data handler from 
FileDataSource.
That way, you let datahandler to set the appropriate mime type.
  dhSource = new DataHandler(new FileDataSource(docFile));

Also make sure there is typemapping registered for DataHandler.

Jai


-----Original Message-----
From: Brian Rook [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 05, 2005 11:12 AM
To: axis-user@ws.apache.org
Subject: attachments question


I'm trying to send back both a string and a zip file from a webservice
built using axis1_2RC1. here's the entry in the wsdl:

    code:


  <schema xmlns="http://www.w3.org/2001/XMLSchema";
targetNamespace="http://websvc.eiwo.childsupport.colorado.gov";
elementFormDefault="qualified">
   <import namespace="http://xml.apache.org/xml-soap"/>
   <complexType name="PendingCaseTO">
    <sequence>
     <element name="confirmationCode" nillable="true" type="xsd:string"/>
     <element name="pendingZip" nillable="true" type="apachesoap:DataHandler"/>
    </sequence>
   </complexType>
  </schema>
  



I can build and deploy and call the service but it fails with this message:

    code:


AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode:
 faultString: java.lang.ClassCastException
 faultActor:
 faultNode:
 faultDetail:
        {http://xml.apache.org/axis/}stackTrace:java.lang.ClassCastException
        at 
javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1056)
        at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:824)
        at 
javax.mail.internet.MimeMultipart.updateHeaders(MimeMultipart.java:215)
        at 
javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1056)
        at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:1914)
        at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:1895)
        at 
org.apache.axis.attachments.MimeUtils.writeToMultiPartStream(MimeUtils.java:201)
  



Here's the line that creates the datahandler:

DataHandler dh = new DataHandler(zipBytes,"multipart/*");

zipBytes is a byte[] and I wasn't sure what to use for the mime type
so I used multipart/*, but that doesn't seem to work.

Are there any suggestions on how to send the attachment correctly?

Thank you

Reply via email to