Base64 Encoding with the SOAP Toolkit...

Tags: Rants

We recently had a project where I tried to encrypt a bit of data (Rijndael), base64 encode it in a VB6 client, and send it over to a .NET managed Web Service via a byte()/byte[].  What a pain in the ass.  Of course this whole thing had to be wrapped up in a complex object, and I decided to use the IXMLDomNodeList method of wrapping up the message.

After spending a complete day trying to figgure out how to do it, and then try to determine why the decryption was not working, I gave up.  This stuff is supposed to be easy.  I definetly do not want to put in place a Transaction based system that rely's on something so flakey. 

We decided to take a step back from it all and determine an alternative method.  I just hate not using the technology.

Anyways, if anyone can show some sample code that actually works I think it would be a create accomplishment.  :)  Both Rijndael and Base64 algorithms are freely available everywhere.

 

 

7 Comments

  • Rob Chartier said

    Nah, we cant deploy .NET on the client machines just yet (they are a few hundred machines spread out over north america with a current deployment of VB6, SOAP Toolkit v3). We are actually starting to plan on making the move to an exclusive .NET environment, but Im afraid that wont be for a little while yet.

  • Simon Jefford said

    Why are you trying to send the base64 encoded date as a byte[]? I thought the whole point of base64 encoding was that it ended up as a string. I have a project (admittedly it's .NET to .NET) which sends potentially non-text data to a remote server. It just encodes the data as a base64 encoded string and passes that string as a parameter to the service.

  • Rob Chartier said

    On the client and the server I attempted to treat both instances of the variable as an array of bytes. Now of course when it goes over the wire i had to do something along the lines of:

    (VB6)

    dim token() as byte

    Call encoding.EncodeB64(token, output)
    Elm.dataType = "bin.base64"
    Elm.nodeTypedValue = output
    Dom0.documentElement.appendChild Elm

    which essentiall produces the xml for my request:

    <Token xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="bin.base64">TWVLazJCY1BTa.....</Token>


    And then on the server I do get the encoded string into my byte[] which works ok, for the first half of the bytes in the array. The second half is usually way off. Single and Dual byte codes are not an issue, transport not an issue. The arrays are of the same length, it just seems that some of the actual bytes are getting mangled somehow. God only knows why.

    Im basically convinced that the To/From Base64 encode is not being handle correctly (maybe the POS library that im using on the client or even the server).

    Bottom line, all of this work to get something that is seemingly simple isnt worth it. Ive already rolled out an alternative acceptable solution.

  • Rob Chartier said

    Well the actual data is very small, only about 100bytes in length and that IMHO DIME would probably overkill (not to mention a real bitch for VB) for implementation.

    On yeah, Don Box mentioned that we should avoid DIME a while back. ugh.

  • Robert Wafle said

    Well, Today is Saturday June 4th, 2006. I'm going to help a friend call a Web Service from VB6 thanks to you guys. :) At least I got him to upgrade his web server to have .NET :)

Comments have been disabled for this content.