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 zolv <zo...@o2.pl> on 2006/08/22 14:36:36 UTC

[axis2] String as attachment

Hi

First of all. I read documentation(s) and I founded only one example how to send an attachment using axis2. In fact, it shows only how to send an image from file. There is no other documentation. This is not all. I noticed (maybe I'm wrong) that in org.apache.axiom.attachments.utils package is only 1 usable class that  - ImageDataSource used in example. What with any others (class or examples)?

Anyway.

Is it possible to send String as attachment? (no, i don't have this string in file etc - just pure String object).
thanx for reply.

frustrated zolv

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: [axis2] String as attachment

Posted by Thilina Gunarathne <cs...@gmail.com>.
> OMFactory fac = OMAbstractFactory.getOMFactory();
>            OMText txt = fac.createOMText("axis2");
>            txt.setOptimize(true);
This string is expected to be a Base64 encoded version of Binary Data.

~Thilina

> ...
>
> or
> byte[] array = "axis2".getBytes();
> DataSource dataSource = new ByteArrayDataSource(array);
>            OMText txt1 = fac.createOMText(dataSource,true);
>
> And set the option,
>
> options.setProperty(Constants.Configuration.ENABLE_MTOM,
> Constants.VALUE_TRUE);
>
> to ServiceClient's Option object.
>
> Saminda
> >
> > frustrated zolv
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-user-help@ws.apache.org
> >
> >
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.1 (GNU/Linux)
> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
>
> iD8DBQFE6xRxYmklbLuW6wYRAtGbAJ0dy0dZs1HuqrUcQL3jpSe6fJb5EwCdH16t
> bjJj6Xt+EoGLDBeacoDMivw=
> =FAgt
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>


-- 
"May the SourcE be with u"
http://webservices.apache.org/~thilina/
http://thilinag.blogspot.com/
http://www.bloglines.com/blog/Thilina

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: [axis2] String as attachment

Posted by Saminda Abeyruwan <sa...@opensource.lk>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Anne Thomas Manes wrote:
> I didn't think that MTOM would "optimize" a string and send it as an
> attachment. MTOM only optimizes binary data fields.
> 
> Why not just send the string as an element in the message?
> 
> Anne
> 
> On 8/22/06, Saminda Abeyruwan <sa...@opensource.lk> wrote:
> 
> zolv wrote:
>> Hi
> 
>> First of all. I read documentation(s) and I founded only one example
> how to send an attachment using axis2. In fact, it shows only how to
> send an image from file. There is no other documentation. This is not
> all. I noticed (maybe I'm wrong) that in
> org.apache.axiom.attachments.utils package is only 1 usable class
> that  - ImageDataSource used in example. What with any others (class
> or examples)?
> 
>> Anyway.
> 
>> Is it possible to send String as attachment? (no, i don't have this
> string in file etc - just pure String object).
>> thanx for reply.
> 
> Yes, absolutely.
> 
> ...
> 
> OMFactory fac = OMAbstractFactory.getOMFactory();
>             OMText txt = fac.createOMText("axis2");
>             txt.setOptimize(true);
Sorry i missed a one important thing, You have to encode the string to
base64 first in first option.

Ex:

OMText txt =
fac.createOMText(org.apache.axiom.om.util.Base64.encode("axis2".getBytes()));
txt.setOptimize(true);

Saminda
> ...
> 
> or
> byte[] array = "axis2".getBytes();
> DataSource dataSource = new ByteArrayDataSource(array);
>             OMText txt1 = fac.createOMText(dataSource,true);
> 
> And set the option,
> 
> options.setProperty(Constants.Configuration.ENABLE_MTOM,
> Constants.VALUE_TRUE);
> 
> to ServiceClient's Option object.
> 
> Saminda
> 
>> frustrated zolv
> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-user-help@ws.apache.org
> 
> 
> 
>>
- ---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
>>
>>

> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFE6/KzYmklbLuW6wYRAjnxAJ4kKTmwjtaCujzyenlKN7Lg92LybQCgpGtt
TFoMZ5oevBInZySkZb120So=
=41Qr
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: [axis2] String as attachment

Posted by Anne Thomas Manes <at...@gmail.com>.
I didn't think that MTOM would "optimize" a string and send it as an
attachment. MTOM only optimizes binary data fields.

Why not just send the string as an element in the message?

Anne

On 8/22/06, Saminda Abeyruwan <sa...@opensource.lk> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> zolv wrote:
> > Hi
> >
> > First of all. I read documentation(s) and I founded only one example how to send an attachment using axis2. In fact, it shows only how to send an image from file. There is no other documentation. This is not all. I noticed (maybe I'm wrong) that in org.apache.axiom.attachments.utils package is only 1 usable class that  - ImageDataSource used in example. What with any others (class or examples)?
> >
> > Anyway.
> >
> > Is it possible to send String as attachment? (no, i don't have this string in file etc - just pure String object).
> > thanx for reply.
>
> Yes, absolutely.
>
> ...
>
> OMFactory fac = OMAbstractFactory.getOMFactory();
>             OMText txt = fac.createOMText("axis2");
>             txt.setOptimize(true);
> ...
>
> or
> byte[] array = "axis2".getBytes();
> DataSource dataSource = new ByteArrayDataSource(array);
>             OMText txt1 = fac.createOMText(dataSource,true);
>
> And set the option,
>
> options.setProperty(Constants.Configuration.ENABLE_MTOM,
> Constants.VALUE_TRUE);
>
> to ServiceClient's Option object.
>
> Saminda
> >
> > frustrated zolv
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-user-help@ws.apache.org
> >
> >
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.1 (GNU/Linux)
> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
>
> iD8DBQFE6xRxYmklbLuW6wYRAtGbAJ0dy0dZs1HuqrUcQL3jpSe6fJb5EwCdH16t
> bjJj6Xt+EoGLDBeacoDMivw=
> =FAgt
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: [axis2] String as attachment

Posted by Saminda Abeyruwan <sa...@opensource.lk>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

zolv wrote:
> Hi
> 
> First of all. I read documentation(s) and I founded only one example how to send an attachment using axis2. In fact, it shows only how to send an image from file. There is no other documentation. This is not all. I noticed (maybe I'm wrong) that in org.apache.axiom.attachments.utils package is only 1 usable class that  - ImageDataSource used in example. What with any others (class or examples)?
> 
> Anyway.
> 
> Is it possible to send String as attachment? (no, i don't have this string in file etc - just pure String object).
> thanx for reply.

Yes, absolutely.

...

OMFactory fac = OMAbstractFactory.getOMFactory();
            OMText txt = fac.createOMText("axis2");
            txt.setOptimize(true);
...

or
byte[] array = "axis2".getBytes();
DataSource dataSource = new ByteArrayDataSource(array);
            OMText txt1 = fac.createOMText(dataSource,true);

And set the option,

options.setProperty(Constants.Configuration.ENABLE_MTOM,
Constants.VALUE_TRUE);

to ServiceClient's Option object.

Saminda
> 
> frustrated zolv
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
> 
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFE6xRxYmklbLuW6wYRAtGbAJ0dy0dZs1HuqrUcQL3jpSe6fJb5EwCdH16t
bjJj6Xt+EoGLDBeacoDMivw=
=FAgt
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org