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 Matthew Fadoul <ma...@my3d.com> on 2008/02/28 09:54:03 UTC

Problem with xs:base64Binary

Hello all,

 

I'm having a little trouble with a field whose type is xs:base64Binary.  I
am looking for a way to populate the associated field in my Java code.  Any
help/sample code would be greatly appreciated.  Here are the details:

 

1) After the wsdl2java conversion, the xs:base64Binary field is represented
by a "javax.activation.DataHandler".

(see
http://java.sun.com/j2ee/1.4/docs/api/javax/activation/DataHandler.html)

 

2) The code examples that I found for DataHandler generally involve things
like files, etc.  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).

  

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.

 

 

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.

 

Thanks!

 

Matt Fadoul

My3D, LLC

 

 


Re: Problem with xs:base64Binary

Posted by Thilina Gunarathne <cs...@gmail.com>.
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
>
>
>
>



-- 
Thilina Gunarathne  - http://thilinag.blogspot.com

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


Re: Problem with xs:base64Binary

Posted by thiamteck <th...@gmail.com>.
Hi,

I have similar requirement for develop a soap client that send base64binary. 

My use case is that i got to convert some of the sensitive info from string
into base64binary, then send it as inline content instead of attachement.

Matt, do you found the solution of:
>         // Insert miracle here, where myString data is sent
>         // to the dataHandler object and turned into
>         // base64 data.

Thilina, in your ByteArrayDataSource example, do I need to configure
somewhere for the base64binary?

Thank you.:-D

Truly,
Thiam Teck



Thilina Gunarathne wrote:
> 
> 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:csethil@gmail.com]
>>  Sent: Thursday, February 28, 2008 9:45 AM
>>  To: axis-user@ws.apache.org
>>  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: axis-user-unsubscribe@ws.apache.org
>>  For additional commands, e-mail: axis-user-help@ws.apache.org
>>
>>
> 
> 
> 
> -- 
> Thilina Gunarathne  - http://thilinag.blogspot.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Problem-with-xs%3Abase64Binary-tp15733036p18863276.html
Sent from the Axis - User mailing list archive at Nabble.com.


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


Re: Problem with xs:base64Binary

Posted by Thilina Gunarathne <cs...@gmail.com>.
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:csethil@gmail.com]
>  Sent: Thursday, February 28, 2008 9:45 AM
>  To: axis-user@ws.apache.org
>  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: axis-user-unsubscribe@ws.apache.org
>  For additional commands, e-mail: axis-user-help@ws.apache.org
>
>



-- 
Thilina Gunarathne  - http://thilinag.blogspot.com

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


RE: Problem with xs:base64Binary

Posted by Matthew Fadoul <ma...@my3d.com>.
Thanks for the help, Thilina.  

Here's a little clarification of my situation:

* I'm creating both the client and server side functionality from my WSDL,
so I don't really have to worry about someone else reading or writing to the
field.

* My use case is basically to use the xs:base64Binary field to pass a long
string that holds space-delimited integers ("0 23 532 12").  The field is
contained in some of my WSDL messages.  Inside my server-side code, I'm
trying to create sample datasets which include the xs:base64Binary  object.
Unfortunately, I'm not quite able to figure out how to use the DataHandler
class and DataSource interface.

So, the simplest code fragment to show what I'd like to do is:

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:csethil@gmail.com] 
Sent: Thursday, February 28, 2008 9:45 AM
To: axis-user@ws.apache.org
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: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org