[Webinar] Streamline your web hosting managementRegister Today


MTOM content transfer Axis2

Posted on 2010-03-25
Medium Priority
Last Modified: 2013-11-19
I have a POJO service in Axis2 which needs to transfer Content to the client. The content transfer mechnism is MTOM.
In the MTOM user guide
following example is given for the server side code

public void uploadFileUsingMTOM(OMElement element) throws Exception {
       OMText binaryNode = (OMText) (element.getFirstElement()).getFirstOMChild();
       DataHandler actualDH;
       actualDH = (DataHandler) binaryNode.getDataHandler();
       ... Do whatever you need with the DataHandler ...

but since I have a POJO web service, I do not have OMElement.
My web service method looks like this

      public GetResumeContentResponse getResumeContent(GetResumeContent getResumeContent) {
       String resumeId = getResumeContent.getResumeId();
       System.out.println("Resume ID is --"+resumeId);
       GetResumeContentResponse res = new GetResumeContentResponse();

Please let me know how can I transfer content using this POJO web service.

Thank You

Question by:ank9
  • 2
LVL 23

Accepted Solution

Siva Prasanna Kumar earned 2000 total points
ID: 28671041
Here is the code:
 GetResumeContentResponse grs = new GetResumeContentResponse();
                	 javax.activation.DataHandler dataHandler = new javax.activation.DataHandler(new FileDataSource("SomeFile"));
                      return grs;

Open in new window


Author Comment

ID: 28935555
Thanks a lot.
Similarly on the client side it says
         ServiceClient serviceClient = new ServiceClient ();
        Options options = new Options();
        options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
        serviceClient .setOptions(options);
Can you please let me know what is targetEPR.
Is it the endpoint? Should it be "
http://localhost:8080/axis2/services/ResumeService" in my case?
thank you

Author Comment

ID: 28936668
In the client, I did the following but an getting these error
1. The method setOptions(Options) is undefined for the type ResumeClient
2. Constants cannot be resolved
I checked the class "org.apache.axis2.Constants.Configuration" but  "FORCE_MIME" was not a field there.
Please let me know which class to import and how to set the options.
Thank you

public static void getResumeContent(String resumeId) {
		System.out.println("Resume ID is getResumeContent --"+resumeId);		
		ResumeClient serviceClient = new ResumeClient();
        Options options = new Options();
        EndpointReference rs = new EndpointReference("http://localhost:8080/axis2/services/ResumeService");
        options.setProperty(Constants.Configuration.FORCE_MIME, Constants.VALUE_TRUE);        

Open in new window


Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question