Hello,
Attachments can be uploaded via SOAP services in BC. This can be done by base64 conversion, If you upload any documents in BC it will be stored in "Document Attachment" table so just convert this attachment into base64 and store it to a "Big Text" variable and by consuming this big text variable you can access the document.
Here I have attached an example, please refer it.
1) If you need to read the attachments from BC SOAP Service follow this method
procedure Attachements(var DocAttachments: BigText)
var
Rec_DocumentAttachment: Record "Document Attachment";
TempBlob: Codeunit "Temp Blob";
Base64: Codeunit "Base64 Convert";
Ostream: OutStream;
Istream: InStream;
Base64Str: Text;
begin
Clear(Base64Str);
Rec_DocumentAttachment.Reset();
if Rec_DocumentAttachment.FindSet() then begin
TempBlob.CreateOutStream(Ostream);
Rec_DocumentAttachment."Document Reference ID".ExportStream(Ostream);
TempBlob.CreateInStream(Istream);
Base64Str := Base64.ToBase64(Istream);
Evaluate(DocAttachments, Base64Str);
end;
end;
2) If you need to upload document from PHP script and need to store the document in BC via SOAP Service then follow this method. Just convert the attachment to base 64 and pass it to the SOAP service
procedure Attachements(DocAttachments: BigText)
var
Rec_DocumentAttachment: Record "Document Attachment";
TempBlob: Codeunit "Temp Blob";
Base64: Codeunit "Base64 Convert";
RecRef: RecordRef;
Ostream: OutStream;
Istream: InStream;
Base64Str: Text;
begin
Base64Str := Format(DocAttachment);
TempBlob.CreateOutStream(Ostream);
Base64.FromBase64(Base64Str, Ostream);
TempBlob.CreateInStream(Istream);
RecRef.GetTable(//Table to which you need to upload the document);
Rec_DocumentAttachment.SaveAttachmentFromStream(Istream, RecRef, FileName);
end;