Following code works for me (axis2 1.4):

      ServiceClient sender = new ServiceClient();
      Options options = new Options();
      options.setTo(targetEPR);
      options.setAction(OPERATION_NAME);
      options.setTimeOutInMilliSeconds(600000);
      options.setProperty(Constants.Configuration.ENABLE_MTOM,
Constants.VALUE_TRUE);
      sender.setOptions(options);
      OMFactory fac = OMAbstractFactory.getOMFactory();
      OMNamespace ns = fac.createOMNamespace("http://www.abc.com/webservice";,
"ns");
      OMElement payload = createPayload(args);
      OMElement retVal = sender.sendReceive(payload);
      if (retVal != null) {
          OMElement ele = retVal.getFirstElement();
          OMText binaryNode = (OMText) ele.getFirstOMChild();
          binaryNode.setOptimize(true);
          return (DataHandler) binaryNode.getDataHandler();
      }
you need to create 'createPayload' method as described in mtom-guide and
attach datahandler.

HTH,
Chinmoy



On Wed, Sep 2, 2009 at 11:29 AM, Partha Pal <[email protected]> wrote:

>  Hi Chinmoy ,
>
>
>
> The java version is 1.5.0_13 .
>
>
>
> Could you pls. provide a link to a complete example to download
> attachments,  as I do not have experience in Axis2.
>
>
>
> Thanks,
>
> Partha
>
>
>
>
>
> *From:* Chinmoy Chakraborty [mailto:[email protected]]
> *Sent:* Wednesday, September 02, 2009 11:16 AM
> *To:* [email protected]
> *Subject:* Re: How to enable MTOM support
>
>
>
> which version of JDK you are using? Axis2 1.5 requires JDK 1.5 onwards.
>
>
>
> Chinmoy
>
> On Wed, Sep 2, 2009 at 10:16 AM, Partha Pal <[email protected]> wrote:
>
> Hi,
>
>
>
> I am writing an axis2 client to get attachment from hosted .NET service. I
> am a newbie so  using the example from
> http://ws.apache.org/axis2/1_0/mtom-guide.html   I am using axis2 1.5 from
> Eclipse 3.3 , this code will eventually go as a plugin. The problem is the
> code :-
>
>
>
> ServiceClient sender = new ServiceClient();
>
>         Options options = new Options();
>
>         options.setTo(targetEPR);
>
>         // enabling MTOM
>
>         options.set(Constants.Configuration.ENABLE_MTOM,
> Constants.VALUE_TRUE);
>
>         options.setTransportInfo(Constants.TRANSPORT_HTTP,
>
>                 Constants.TRANSPORT_HTTP, false);
>
>
> options.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
>
>
>
>         OMElement result = sender.sendReceive(payload);
>
>         OMElement ele = result.getFirstElement();
>
>         OMText binaryNode = (OMText) ele.getFirstOMChild();
>
>
>
>         // Retrieving the DataHandler & then do whatever the processing to
> the data
>
>         DataHandler actualDH;
>
>         actualDH = binaryNode.getDataHandler();
>
>         Image actualObject = new
> ImageIO().loadImage(actualDH.getDataSource()
>
>                 .getInputStream());
>
>
>
>
>
> Is not compiling . There is no
>
>       options.set(Constants.Configuration.ENABLE_MTOM,
> Constants.VALUE_TRUE);
>
>
>
>       I am using org.apache.axis2.client.Options . Am I missing some thing
> ? could anybody please point me any other resource for MTOM with Axis2 !
>
>
>
> Thanks,
>
> Partha
>
>
>
>
>

Reply via email to