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 Eyad Garelnabi <eg...@touchpoint.ca> on 2004/11/30 16:53:13 UTC
desperate newbie-- trouble with image attachment
Hi,
I'm an axis newbie and having trouble sending an image attachment
(document style message) from my client to the server. The attachment
seems to go across fine, but when I use AttachmentPart on the server,
the server hangs. It tries to write the binary source to the
console/screen and the PC beeps endlessly, and it hangs. I've been at
this for ten days now trying to figure out what the problem is. No one
at work has much experience with axis so I'm on my own on this one. Any
tips whatsoever on what it is I'm doing wrong would be very much
appreciated.
I've attached the following files:
RemoteTaskResultService (client-side), RemoteTaskResultImpl
(server-side), remotetaskresult (wsdl)
I'm using Axis 1.1, Tomcat 4.1.x
Thanx a million
Re: desperate newbie-- trouble with image attachment
Posted by Vy Ho <st...@drexel.edu>.
This should not be too hard.
Let's take 5 to 10 minutes to get it to work.
1) start with an interface:
public interface ImageService{
public void sendImage(DataHandler data);
}
save that to a file named ImageService.java
Also, add proper package for the class and import statements for
DataHandler.
2) Use Java2Wsdl to generate the Wsdl file. You can open and see if it
work or not.
3) Use Wsdl2Java to generate all the stubs and whatnots.
4) Implement your sever:
public void sendImage(DataHandler data){
try{
//data.getInputStream();
//the above is the binary data for your image, save it to
file, or do whatever it takes. Do
//not print it out to the screen, because you'll get alot
of beeps.
}catch(Exception e){
e.printStackTrace();
}
}
5) Deploy the server by compiling all your stuffs, copy to the server's
classes directory and also copy the content of deploy.wsdl to the axis
config file.
6) Write the client:
public void send myStuff(String imageFileName){
try{
DataHandler data = null;
FileDataSource fds = new FileDataSource(imageFileName);
//assume it's in a file for now, play with it if it's not
data = new DataHandler(fds);
ImageService service = null;
//Create a new service locator for ImageService , note that
this is generated by Wsdl2Java
//set the server's address:
//set whatever thing you need such as document or whatever, this
is optional, after getting this to work, do this later.
//call the service
service.sendImage(data);
}catch(Exception e){
}
}
Note that I haven't test this code, but it should work with minor twist.