Skip to Content
0

Storing String data in Binary Object - Need to store a PDF-File from Webservice as an attachment.

Nov 18, 2016 at 08:18 PM

433

avatar image

Hi Experts,

Please loot at my bellow code.

// Webservice Reponse, already base-64 converted, No need to convert again.
var ReponseString = ws_result.Content; 
var binaryString : BinaryObject;
this.binaryData.content = ReponseString ;
//Warning.  ReponseString  is having value. Debugging: Empty value return.

Is there any other way to store string in binary object? Am I missing anything in above code?

Regards

Sankaran A

10 |10000 characters needed characters left characters exceeded

Hi Sankaran,

please did you found a solution how to resolv this issue?

i'm facing the same problem and i laking ideas, please let me know if you have found a solution.

Best Regards

Stéphane

0
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Marlos Augustus Maciel Damasceno Nov 21, 2016 at 05:43 PM
0

Hi Sankaran,

You said that your return from the web service is already on Base64. Did you try the follow:

var docType : DocumentTypeCode;
var binaryObject : BinaryObject;
var docDesc : Description;
var docName : LANGUAGEINDEPENDENT_Name;
var docAltName : LANGUAGEINDEPENDENT_Name;
docAltName = "altName";

var ReponseString = ws_result.Content; 
docName = "NameOfDoc.pdf";		
docDesc.content = "Your description of the document";
docType.content = "10001"; /*Standard Attachment*/
binaryObject.mimeCode = "application/pdf";	

/*Here is the important line*/	
binaryObject.content = Binary.ParseFromBase64String(ReponseString); 
this.AttachmentFolder.CreateFile(docType, docName, docAltName, docDesc, binaryObject);	

I hope this help

Regards

Show 4 Share
10 |10000 characters needed characters left characters exceeded

Thank you much @Marlos

Regards

Sankaran A

1

You are welcome Sankaran!

Best regards

0

Hi Augustus,

i even use your proposition but i still get a failure when i try to read the pdf file with Acrobat Reader DC

Best Regards

Stephane.

0

Hi Stephane,

I have to make sure that your string is in base64, otherwise it will generate an error. You may try to convert an PDF file to a Base64 string (here). And, use this hard coded string to check if the parser on C4C was ok.

I did no try to do this, but it may work and give you an direction to go.

Best regards

Marlos Damasceno

0
wenlei Peng Nov 21, 2016 at 01:24 AM
0

Hi Sankaran,

I also encountered the same problem.

You can try WebServiceUtilities.EncryptWithHashBasedMessageAuthenticationCode() the method.

Unfortunately,I did not find the relevant documents about the method paraments.

Thanks and Regards,

Eric

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Eric,

Thanks for your feedback.

Regards

Sankaran A

0
Horst Schaude
Nov 21, 2016 at 12:58 PM
0

Hello Sankaran,

What about using the DO AttachmentFolder?
Just use the action CreateFile which supports a parameter DocumentFileContentBinaryObject.

HTH,
Horst

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Horst,

Thanks a lot. It is working.

Regards

Sankaran A

0