• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Adding attachments to web service response

 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. We were a little "stuck" on using Axis 1.4, but will be expanding a bit to include WSO2 WSAS with Axis2 in our evaluations.

 
shivendra tripathi
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
AXIS 1.4 support soap with attachment (SWA) though it's not support MTOM which is optimized way of sending attachment.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
shivendra tripathi
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
shivendra tripathi
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

In the second case, with Axis 1.4, adding the attachment to the web service SOAP response is not possible.



I disagree with above. Do you want to say that axis 1.4 doesn't support SWA?
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
shivendra tripathi
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Pinkerton wrote:Firstly, do you understand this statement clearly?



I tried giving you some pointer to start with but that seems useless. Follow the link below which tells how to implement it in server side.

http://www.roseindia.net/webservices/web-services-development.shtml


 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for you help.

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.

Processing (incoming) attachments != 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.
 
Greenhorn
Posts: 2
Eclipse IDE Tomcat Server Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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

reply
    Bookmark Topic Watch Topic
  • New Topic