Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to make a WebServices call return DataHandler object within WebObjects?  RSS feed

 
huan xie
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I m developing a WebServices function to download and upload files


//Server Side
public void addAttachment(String fileName, DataHandler fileHandler){
File destFile = new File("/usr/desktop/test");
destFile.createNewFile();
FileOutputStream stream = new FileOutputStream(destFile);
fileHandler.writeTo(stream);
}

public DataHandler downloadAttachement(){
DataHandler dataHandler = new DataHandler(new FileDataSource("/usr/desktop/test.rtf"));
return dataHandler;
}

The first function works, but now the second one? Anyone know the reason?
I m using WebObjects and Axis1.4
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think javax.activation.DataHandler objects are intended to be used outside an application and thus can not be passed around.

How are you expecting this web service to be used? What is supposed to be running on the client side?

Bill
 
huan xie
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William Brogden wrote:I don't think javax.activation.DataHandler objects are intended to be used outside an application and thus can not be passed around.

How are you expecting this web service to be used? What is supposed to be running on the client side?

Bill


Client Side: generate the java code via wsdl2java and call the service directly

// Get handle to the service
Request_Service service = new Request_ServiceLocator();
Request_PortType port = service.getRequest(requestURL);

DataHandler dh = new DataHandler(new FileDataSource("/Users/test/Desktop/test.rtf"));
port.addAttachment("test.rtf", dh);

I tested this, it works well
The only problem is downloadAttachment doesn't work
 
huan xie
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The file name and directory are just examples, I have the addAttachment function works already
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!