You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Partha Pal <pa...@kovair.com> on 2009/09/02 06:46:42 UTC

How to enable MTOM support

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

 


RE: How to enable MTOM support

Posted by Partha Pal <pa...@kovair.com>.
Hi Amila ,

 

Axis2-kernel-1.5.jar in classpath, in fact classpath contains all jars
from axis2 lib.

 

Thanks,

Partha

 

From: Amila Suriarachchi [mailto:amilasuriarachchi@gmail.com] 
Sent: Wednesday, September 02, 2009 1:30 PM
To: axis-user@ws.apache.org
Subject: Re: How to enable MTOM support

 

 

On Wed, Sep 2, 2009 at 10:16 AM, Partha Pal <pa...@kovair.com> 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);


seems you don't have axis2-kernel jar in your class path. Add all the
axis2/lib jars to your class path.

thanks,
Amila. 

	 

	      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

	 




-- 
Amila Suriarachchi
WSO2 Inc.
blog: http://amilachinthaka.blogspot.com/


Re: How to enable MTOM support

Posted by Amila Suriarachchi <am...@gmail.com>.
On Wed, Sep 2, 2009 at 10:16 AM, Partha Pal <pa...@kovair.com> 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);
>

seems you don't have axis2-kernel jar in your class path. Add all the
axis2/lib jars to your class path.

thanks,
Amila.

>
>
>       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
>
>
>



-- 
Amila Suriarachchi
WSO2 Inc.
blog: http://amilachinthaka.blogspot.com/

Re: How to enable MTOM support

Posted by Chinmoy Chakraborty <cc...@gmail.com>.
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 <pa...@kovair.com> 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:cchinu@gmail.com]
> *Sent:* Wednesday, September 02, 2009 11:16 AM
> *To:* axis-user@ws.apache.org
> *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 <pa...@kovair.com> 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
>
>
>
>
>

RE: How to enable MTOM support

Posted by Partha Pal <pa...@kovair.com>.
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:cchinu@gmail.com] 
Sent: Wednesday, September 02, 2009 11:16 AM
To: axis-user@ws.apache.org
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 <pa...@kovair.com> 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

 

 


RE: How to enable MTOM support

Posted by Partha Pal <pa...@kovair.com>.
1.5.0_13 

 

From: Chinmoy Chakraborty [mailto:cchinu@gmail.com] 
Sent: Wednesday, September 02, 2009 11:16 AM
To: axis-user@ws.apache.org
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 <pa...@kovair.com> 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

 

 


Re: How to enable MTOM support

Posted by Chinmoy Chakraborty <cc...@gmail.com>.
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 <pa...@kovair.com> 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
>
>
>