• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

New Here ,
Dec 15, 2014 Dec 15, 2014

Copy link to clipboard

Copied

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#>

    </cffunction>

</cfcomponent>

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"

           refreshWSDL="yes"

           sourceWebPageURL="#webPageURL#"

           returnVariable = "pdfDoc">

</cfinvoke>

<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! 

Views

213

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation
Resources
Documentation