Win a copy of Terraform in Action this week in the Cloud forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

processing attachments in web service

 
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic