First of all I wonder why do you want to send a plain string using
base64Binary.. Is it a huge string and do you want to send it as an
attachement?..
Use org.apache.axiom.attachments.ByteArrayDataSource..
String test = "test";
ByteArrayDataSource dataSource = new
ByteArrayDataSource(test.getBytes());
DataHandler dataHandler = new DataHandler(dataSource);
Other way round,
InputStream inputStream = dataHandler.getInputStream();
Read the content to a byte[].. Create the string from that byte[]...
thanks,
Thilina
>
> public DataHandler convertStringToBase64Binary (String myString) {
> // Example myString value = "0 23 532 12";
>
> DataHandler myBase64BinaryField;
>
> // Constructor for DataHandler...
>
> // Insert miracle here, where myString data is sent
> // to the dataHandler object and turned into
> // base64 data.
>
> return myBase64BinaryField;
> }
>
> It would be interesting to see the other direction (i.e. DataHandler to
> String) as well.
>
> * As I mentioned in my previous message, the easy solution is to just send
> the data as an xs:string, which works for me since I'm creating both the
> client- and the server-sides of the web service. That said, I am still
> interested in understanding the mechanics of DataHandler.
>
> Thanks again,
>
> Matt Fadoul
> My3D, LLC
>
>
> -----Original Message-----
> From: Thilina Gunarathne [mailto:[EMAIL PROTECTED]
> Sent: Thursday, February 28, 2008 9:45 AM
> To: [email protected]
> Subject: Re: Problem with xs:base64Binary
>
> Hi,
> > 2) The code examples that I found for DataHandler generally involve things
> > like files, etc.
>
> Yep... It can even be a byte[].. base64Binary data type stands for
> base64 encoded binary data.. Hence everything that involves
> Datahandlers work in binary(byte) level..
>
> > For example:
> > http://ws.apache.org/axis2/1_2/mtom-guide.html#21
> > (Note: It seems that the lines of code with OMText aren't complete).
>
> ouch... Please use the newest version.. It seems to be complete..
> http://ws.apache.org/axis2/1_3/mtom-guide.html#21
>
>
> > 3) In my case, my data is much simpler. For example, if I could populate
> > the field with a string (e.g. "0 23 532 12"), that would be sufficient.
>
> What's your exact use case.. What are you trying to send in that
> field.. Do you already have a base64 encoded string with you??
>
>
> > My quick solution is to just change this field's type to xs:string. The
> > reason I'd like to keep it xs:base64binary is because it's someone else's
> > schema, so I wanted to stay faithful to their data types.
>
> Please find out what kind of data (semantics) is he expecting, whether
> it's image or a signature etc... It's ok to change it to string.. But
> you would need to make sure to set the content to a base64 encoded
> string of the expected type..
>
> thanks,
> Thilina
> >
>
> > Thanks!
> >
> > Matt Fadoul
> >
> > My3D, LLC
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
Thilina Gunarathne - http://thilinag.blogspot.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]