• Post Reply Bookmark Topic Watch Topic
  • New Topic

to anyone who has used axis & SAAJ (urgent)

 
carlos sanchez
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm developing a web service that has to send attachment's.
First Problem. java2WSDL when trying to generate the wsdl from a method like this:
<code>
public String check(DataHandler dh)
{
if(dh == null)
{
System.err.println("Attachment vacio");
return "error";
}
else
{
String filename = dh.getName();
System.out.println("nombre del archivo: " + filename);
try
{
int c;
File receivedfile = new File(filename);
FileOutputStream fos = new FileOutputStream("/apps/tomcat/Axis_Standalone/webapps/temp/"+filename);
FileInputStream fis = new FileInputStream(filename);
while ((c = fis.read()) != -1)
{
fos.write(c);
}
}
catch(Exception e)
{
e.printStackTrace();
return "error";
}
return "ok";
}
}
}
</code>
I get a : "The class javax.activation.DataHandler is defined in a java or javax package and cannot be converted into an xml schema type. An xml schema anyType will be used to define this class in the wsdl file."
-------------------------------------------------------------------------
So I went on (despite of this message) I've built the skeletons and casted the object I get. then I built the client:
<code>
DataHandler dhSource = new DataHandler(new FileDataSource("C:/dump.mp3"));
String endpoint = "http://tpid01:8500/axis/services/CheckAttachService";

Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(endpoint) );
call.setOperationName(new QName("http://tpid01:8500/", "check"));
QName qnameAttachment = new QName("urn:CheckAttachmentService","DataHandler");
call.registerTypeMapping(dhSource.getClass(),qnameAttachment,JAFDataHandlerSerializerFactory.class,JAFDataHandlerDeserializerFactory.class);
call.addParameter("source",qnameAttachment,ParameterMode.IN);
call.setReturnType(new QName("urn:CheckAttachmentService","String"));
String respuesta = (String) call.invoke( new Object[] {dhSource} );

</code>
and got a:
FaultCode: Server.userException
FaultCode: ; nested exception is:
java.io.IOException: No support for attachments
--------------------------------------------------------------------------
So, im stuck, help apreciated..
 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Few things!..
Have you defined the WSDD properly ??
Are you able to run the echo attachment demo included in the axis samples ?if so you can copy the logic/code from there and get your job done.
 
David DeCesare
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may have already done this, but did you load the activation.jar and mail.jar files into Tomcat? You'll need those files to use attachments.
You can run happyaxis.jsp to check.
David
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!