In the Axis framework, there is a WSDL2Java program which creates a set of Java objects for deploying a web service.
If I run WSDL2Java on a WSDL file, I will get a group of class files. Can a file attachment be added with these classes, i.e. in the {XXX}SoapBindingImpl object?
If not, is there anyway to directly add a file attachment to the outgoing SOAP repsonse?
I am not sure if attachment can be added to generated classes. But it can be vary well added to the response. You can have a look into SOAP with Attachment (SWA) specifications or MTOM. Both of them are supported by AXIS2.
Sending a SOAP message with attachments to a web service and a web service that sends a SOAP repsonse with attachments are two different things.
In the first case, adding the attachement is relatively simple. In the second case, with Axis 1.4, adding the attachment to the web service SOAP response is not possible. There is no way to get to the generated SOAP message.
As per SWA spec attachment will not be part of SOAP message. SOAP message will just have reference of attachment. SOAP message will go as root part of mime type multipart/related while attachment will go in next part. There is another way though it will increase the size of attachment by 1.3 times. Have a base64binary type of element to carry attachment. And do encoding and decoding of your attachment.
As per SWA spec attachment will not be part of SOAP message. SOAP message will just have reference of attachment. SOAP message will go as root part of mime type multipart/related while attachment will go in next part.
Yes, this is correct. It does not have anything to do with what I just mentioned however.
As I mentioned, a client sending a SOAP message with attachments to a web service (request) and a web service which sends a SOAP message with attachments to a client (response) are different.
Firstly, do you understand this statement clearly?
Basically, we want to create a web service that sends file attachments via SOAP to the client.
However, the author in this article attempts to shows how to create a web service that can process incoming attachments from the client. As mentioned already a few times, this is not what this post is about.
The article does not demonstrate a web service sending outgoing attachments.
Client code for sending attachments is not the same as web service code sending attachments. The attachments being sent to a web service and attachments sent to client are not the same.
PS: roseindia.net is website full of bad practices and buggy code.
I know this thread is a little old but i am in the exact same situation as Jimmy.We are stuck with Axis 1.4 and we need a web service that has an invoice number (int) in request and the spits out a response with a pdf file as an attachment.
As others i have gone over tons of examples on the web with some built in axis 2 and others which send attachments as part of the request(like a resume upload service).If some one can point me the right direction or provide some code i can run to see how sending an attachment as part of the response works it will be really helpful.Thanks