aspose file tools
The moose likes Web Services and the fly likes processing attachments in web service Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Web Services
Reply Bookmark "processing attachments in web service" Watch "processing attachments in web service" New topic
Author

processing attachments in web service

Tom Griffith
Ranch Hand

Joined: Aug 06, 2004
Posts: 256
Hello. if anybody has a minute, I can't seem to get a grasp on this. I have a web service that accepts parameters and returns a response string, no problem. I modified the client to send an attachment. however, I can't figure out how to make the web service implementation class process attachments. It seems to begin with having to obtain a handle to the incomng SOAPMessage, right...via SOAPMessageContext and MessageContext? Therein lies my problem (if what i said is true)...i can't figure out how to obtain or instantiate the/a MessageContext inside the web service...

something along the lines of...

MessageContext context = MessageContext.getCurrentContext();

does anybody have an example that begins before a MessageCntext object is created? Again, i just don't know how to instantiate a MessageContext inside the web service (if that is indeed the approach). Is it similar to servlets on some level where I need to obtain the request object?

Thank you very much for reading and for your time.
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2906
You didn't mention which technology you are using.

JAX-RPC :
In a SOAP Message handler it is handed to you:

javax.xml.rpc.handler.Handler.handleRequest(javax.xml.rpc.handler.MessageContext context);
javax.xml.rpc.handler.Handler.handleResponse(javax.xml.rpc.handler.MessageContext context);


In a JAX-RPC Servlet endpoint (JSE) you get it through ServiceEndpointContext.getMessageContext()


In an EJB endpoint you get it through SessionContext.getMessageContext().



That being said attachments in JAX-RPC are usually being handled with javax.activation.DataHandler.

SOAP attachments with JAX-RPC

This makes some sense as "SOAP with Attachments" are actually sent in a multi-part MIME envelope (the SOAP envelope travels in the first part) and DataHandlers were designed to deal with the serialization/de-serialization of MIME types.



JAX-WS 2.0:
You get the MessageContext through WebServiceContext.getMessageContext()



Faster Data Transport Means Faster Web Services with MTOM/XOP


"Don't succumb to the false authority of a tool or model. There is no substitute for thinking."
Andy Hunt, Pragmatic Thinking & Learning: Refactor Your Wetware p.41
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: processing attachments in web service
 
Similar Threads
How to get the contents of message from the soap request
Problem in Attachments
a sample web service that could receive a soap message with attachment.
Binary SOAP attachment using Websphere
Attachment problem