Byte Array Base64 Binary
I'm currently working on code to consume a soap webservice in cf8. I have most of the
implementation working and am able to use several of the methods defined in this
particular WS without issue. I'm having a problem with a particular function that
sends a PDF document to the WS. In the WS docs it lists the document 'content'
field as needing to be base64binary and from talking to the developers they say it
specifficly needs to be a byte array of base64binary.
Here's a snippet of the coldfusion code I'm using:
<cffile action="readbinary" file="#arguments.filepath#" variable="documentBinaryData"/>
<cfsavecontent variable="soapBody">
<cfoutput>
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<AddDocument xmlns="http://idoccentral.com">
<IKey>#arguments.iKey#</IKey>
<documentDetail>
<Source>#arguments.source#</Source>
<FolderID>#arguments.folderID#</FolderID>
<DocumentID>0</DocumentID>
<DisplayName>#arguments.displayName#</DisplayName>
<DocumentDescriptionID>0</DocumentDescriptionID>
<DocumentDescription>#arguments.documentDescription#</DocumentDescription>
<FileType>#arguments.fileType#</FileType>
<Content>#BinaryEncode(documentBinaryData,"Base64")#</Content>
</documentDetail>
</AddDocument>
</soap:Body>
</soap:Envelope>
</cfoutput>
</cfsavecontent>
<cfhttp url="http://stage.doccentral.trpoint.com/DCWebService/IDCService.asmx" method="post" result="httpResponse" timeout="600" throwonerror="yes">
<cfhttpparam type="header" name="SOAPAction" value="http://idoccentral.com/AddDocument"/>
<cfhttpparam type="header" name="accept-encoding" value="no-compression"/>
<cfhttpparam type="xml" value="#trim(soapBody)#"/>
</cfhttp>
The WS response is telling me that everything was ok, I can see the file on the
remote system but when i try to view it from there i get a corrupt file as if my encoding
is incorrect or they are not decoding it correctly.
I've used this same method before for a different web service that also recieves
base64binary encoded PDF documents and it's working just fine there.
As far as i can tell im encoding it to base64Binary correctly, not sure about the
byte array part but im assuming thats whet the cffile readbinary is returning.
Am i doing something wrong in my code or is it more likely to be something on
their end or something wrong in my header?