0 Replies Latest reply on Dec 15, 2014 9:07 AM by ice_cold_ice

    How to Pass a URL to a CF 10 web service and get a PDF doc?


      I've searched everywhere for a solution, but I didn't see anyone doing exactly what I want to do, even though it's pretty simple.  Here is my pdfAPI.cfc code:


      <cfcomponent  >

          <cffunction name="pdfconvert" access="remote" returntype="binary" output="false"  produces="application/xml" > 

              <cfargument name="sourceWebPageURL" type="string" >


              <cfset pdfDoc = "" > 


              <cfdocument format="PDF" name="pdfDoc" src="#sourceWebPageURL#"  mimetype="text/html" />  


              <cfreturn #pdfDoc#>




      And here is the code to invoke the service:


      <cfset wsURL = "http://www.mywebservice.com/cfc/pdfAPI.cfc">


      <cfset webPageURL = "http://www.mywebcontent.com/COEMembers.cfm" >


      <cfinvoke webservice = "#wsURL#"

                 method = "pdfconvert"



                 returnVariable = "pdfDoc">



      <cffile action="write" output=#ToBase64(pdfDoc)#  file="Centers_of_Excellence.pdf" >


      The error I get states

      Unable to parse WSDL as an XML document.

      Parsing error: XML document structures must start and end within the same entity.


      Since the WSDL is not written by me, it's not subject to human error.  So the problem is somewhere in my CF code.


      The code is simple enough that anyone should be able to give it a whirl.  In the last tag, cffile, I'm not sure whether I should use ToBase64 or ToBinary, but I haven't gotten that far yet. Also, not sure if cfdocument can be an empty tag, but if i put in a closing "/cfdocument" tag, what would go between the tags?  The src attribute should provide me with everything I need in my PDF doc.  Thanks to all who can give me a hand with this!