SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jun 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    create/Invoke webservice that returns pdf

    Trouble invoking webservice that returns pdf in return.

    Question:--

    1) "what should be the return type of webservice when it returns "PDF" file?
    2) What retrun type does the webservice returns?
    3) Do I have to to <cfcontent type="application/pdf"> before webservice consuming code?
    4) How should I invoke the webservice?

    Below is the error and code I am using for this purpose. Can anyone please point out the errors in my code?

    Error:-
    Code:
    Cannot perform web service invocation getCreatePDF.
    The fault returned when invoking the web service operation is:
    AxisFault
     faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
     faultSubcode: 
     faultString: org.xml.sax.SAXParseException: Content is not allowed in prolog.
     faultActor: 
     faultNode: 
     faultDetail: 
         {http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXParseException: Content is not allowed in prolog.
         at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
         at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
         at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
         at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
         at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentScannerImpl$PrologDispatcher.dispatch(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
         at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
         at org.apache.xerces.parsers.XML11Configuration.pars... ''

    Here is my webservice component.

    Code:
    <cffunction name="getCreatePDF" access="remote" displayname="createPDF" returntype="binary">
         <cfsavecontent variable="returnString">
         <cfdocument format="PDF">
                <cfdocumentitem type="header">National Parks Report</cfdocumentitem>
                <!--- Use a footer with current page of totalpages format --->
                <cfdocumentitem type="footer">
                  &nbs p;    <cfoutput>Page #cfdocument.currentpagenumber# of #cfdocument.totalpagecount#</cfoutput>
              </cfdocumentitem>
     
              <h1>Park list</h1>
              <table width="95%" border="2" cellspacing="2" cellpadding="2" >
               <tr >
               &nbs p;      <th>Park</th>
                 &nbs p;     <th>Manager</th>
                </tr>
              </table>
         </cfdocument>
         </cfsavecontent>
         <cfreturn returnString>
    </cffunction>
    Here is my webservice consuming code:
    Code:
    <cfset objAPI = CreateObject("webservice", "http://localhost:8060/WebServices1.cfc?wsdl")/>
     
    <cfset objAPI._setProperty("Cookie", "myCookie1=hello")>
    <cfset objAPI.setMaintainSession(true)>
    <cfset objAPI.init()/><br>
    <!--- <cfcontent type="application/pdf"> --->
    <cfset myResult=objAPI.getCreatePDF()>
    <cfset myResult1 = BinaryEncode(myResult,'Base64')>
     
    <cfoutput>
    #myResult1#
    </cfoutput>

  2. #2
    SitePoint Addict
    Join Date
    Dec 2008
    Location
    Aberdeen, Scotland
    Posts
    379
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How about a different approach....

    1) Call the webservice and get that to create the PDF and save it on the filesystem. The web service then returns a URL to the location of that PDF.

    2) On your CFM page then call the PDF on the returned URL using CFCONTENT to display. At the same time you might want to also delete the PDF on view?

    HTH

    Cheers,
    James


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •