1

Please help I am having problem with correct encoding Clinical Document to base 64 and sending it to the Document object. Here is code I am using.

1.step I am encoding PDF file to Base64

byte[] bytes = System.IO.File.ReadAllBytes(pdffile); 
return Convert.ToBase64String(bytes);

This string attached to Clinical documet

2.Attaching CDA document to Metadata submission request

byte[] bytes = System.IO.File.ReadAllBytes(CDADocument.xml);
string ReturnValue = Convert.ToBase64String(bytes);
byte[] newbyte = System.Text.Encoding.UTF8.GetBytes(ReturnValue);

doc[0].Value = newbyte;

Submission request passes all steps but decoding is not working. They are using Java API to decode the submission request. Thank you for your help

3
  • What is a Clinical Document? Commented Sep 8, 2011 at 19:22
  • 1
    Obvious question... if .Value is byte[], why not just give it bytes instead of base-64 and utf-8? Commented Sep 8, 2011 at 19:23
  • I can not use bytes because I have to encode to base64 first.Base64 returs string but value parameter expects Byte Commented Sep 8, 2011 at 19:43

2 Answers 2

2

Make sure that the options for both are the same.

For example, C# will pad by default, with '='. Java may not be expecting it to be padded.

There may be other incompatible options, like adding new line on end, or in the middle to split on to multi-lines, but padding is the most obvious one I would say.

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

3 Comments

Thank you I don't have access to decoding programm.Is it possible to put some code to match with Java decoding.How I would know if pad ornew lines are different.
thank you very much for this comment, I am new in C#. Is there any code to match encoding and decoding between C# and Java?
Sorry I don't have anything, the only java I do is android.Did they give you a spec that specified UTF-8?
0

I am using base64 to pass data from asp.net c# server code to java applet and there are no problems.
The only problem that you may have here is the UTF8 part.
UTF8 (or any other encoding) must be used by both parties while encoding and decoding.

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.