2

I has a fairly standard method that base64-encodes a string prior to sending that string over the wire to a client. When the communication was SOAP, everything worked fine but now that everything is running through the .NET version of JSON, the base64 decoding is blowing up with the error:

The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.

I noticed that .NET was adding a \" to the beginning and end of the string so I removed those and then I checked the length and noticed that it was not a multiple of 4 so I padded the beginning and end as needed with equal signs - nothing helped. I still get the same error noted above no matter what I do.

I am stuck and nobody else's answers to similar questions has helped - any ideas (and, no, I cannot get rid of .NET...)?

The string from the server is:

zkWv1UuGZX08g1s/k/Rp4edZJ/QkuQO88HxpWtpsSfZt4kdWotuqzDy7+YgrB/JUdmuU7FB7thtK1yah+bW0CL3NPP/WGeQHjL/pvpoaOVAiDODnXOvONwuMINpSTa6HvxHj5mJxDvIoEhUwzchFfxfjnDW6tGutBRCBhGHYTK4=

The string received on the client prior to me mucking around with it is:

\"zkWv1UuGZX08g1s\/k\/Rp4edZJ\/QkuQO88HxpWtpsSfZt4kdWotuqzDy7+YgrB\/JUdmuU7FB7thtK1yah+bW0CL3NPP\/WGeQHjL\/pvpoaOVAiDODnXOvONwuMINpSTa6HvxHj5mJxDvIoEhUwzchFfxfjnDW6tGutBRCBhGHYTK4=\"

9
  • 1
    .Net does not add a \" to the beginning and end of the string; that's the way the debugger displays it. Please show us your code. Commented Mar 12, 2012 at 5:47
  • Actually that is not the Debugger as the string is: Commented Mar 12, 2012 at 5:55
  • "\"zkWv1UuGZX08g1s\/k\/Rp4edZJ\/QkuQO88HxpWtpsSfZt4kdWotuqzDy7+YgrB\/JUdmuU7FB7thtK1yah+bW0CL3NPP\/WGeQHjL\/pvpoaOVAiDODnXOvONwuMINpSTa6HvxHj5mJxDvIoEhUwzchFfxfjnDW6tGutBRCBhGHYTK4=\"" Commented Mar 12, 2012 at 5:55
  • You're probably making a mistake somewhere. Please show us your code. Commented Mar 12, 2012 at 6:08
  • Make sure your strings don't have a literal \" when you send them. It looks like you're adding them in when you shouldn't. Commented Mar 12, 2012 at 6:14

1 Answer 1

2

The problem is that JSON escapes a bunch of characters and returning a string escapes its own set of characters. There are some great posts in here about Streaming WCF JSON repsonses that can help out on the return but nothing that addressed the incoming. I switched to XML from JSON.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.