Link to home
Start Free TrialLog in
Avatar of ank9
ank9

asked on

MTOM content transfer Axis2

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
http://ws.apache.org/axis2/1_5/mtom-guide.html
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();
     
       //res.setContent(content);
}

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

Thank You

ASKER CERTIFIED SOLUTION
Avatar of Siva Prasanna Kumar
Siva Prasanna Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ank9
ank9

ASKER

Thanks a lot.
Similarly on the client side it says
         ServiceClient serviceClient = new ServiceClient ();
        Options options = new Options();
        options.setTo(targetEPR);
        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
Avatar of ank9

ASKER

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.setTo(rs);
        options.setProperty(Constants.Configuration.FORCE_MIME, Constants.VALUE_TRUE);        
        serviceClient.setOptions(options);
	}

Open in new window