I decided to go ahead and put a test page together for the DWFRender Web Service. It still wasn't feasible to make it part of the blog itself, given the issues with scripting, particularly, but I've included the files here for you to download and run locally:
Download freewheel_web_service_test.zip
There are three web methods called by this code:
- pdkVersion - gets the version of the PDK on the server (a string value)
- pageCount - gets the number of pages for a particular DWF file (an integer value)
- load - gets more detailed information about each page in a DWF (a more complex data structure is used for this)
Web Services are generally called asynchronously from HTML, which means the call is made and the page then sits back until either a callback is invoked or an event is fired (the Web Service Behavior used in the attached sample - and linked to in my previous post - can be made to work with both approaches... I've chosen to use callbacks in my code, as it allows more flexibility when handling different result types: you can have different callback functions invoked depending on the datatype you expect to receive).
The first two methods will return basic dataypes - here are typical results without the SOAP header:
<pdkVersionResult>1.4.1976.5fw</pdkVersionResult>
<pageCountResult>5</pageCountResult>
Inside the attached code it is simple to access these datatypes by using result.value in the callback receiving the results.
For the load method, however, things are more complicated. As a complex datatype is used to return the information about the various pages, you will need to use result.raw.xml to access the underlying XML content:
<loadResponse xmlns="http://autodesk.com/DWFRender">
<loadResult>
<pageCount>5</pageCount>
<sectionInfo>
<SectionInformation>
<name>Assembly Exploded:1</name>
<paperSize>
<units>kMillimeters</units>
<width>431.8</width>
<height>279.40000000000003</height>
</paperSize>
</SectionInformation>
<SectionInformation>
<name>Assembly:2</name>
<paperSize>
<units>kMillimeters</units>
<width>431.8</width>
<height>279.40000000000003</height>
</paperSize>
</SectionInformation>
<SectionInformation>
<name>Sony PSP Body:3</name>
<paperSize>
<units>kMillimeters</units>
<width>431.8</width>
<height>279.40000000000003</height>
</paperSize>
</SectionInformation>
<SectionInformation>
<name>UMD COVER:4</name>
<paperSize>
<units>kMillimeters</units>
<width>279.40000000000003</width>
<height>215.9</height>
</paperSize>
</SectionInformation>
<SectionInformation>
<name>MAGIC GATE COVER:5</name>
<paperSize>
<units>kMillimeters</units>
<width>279.40000000000003</width>
<height>215.9</height>
</paperSize>
</SectionInformation>
</sectionInfo>
</loadResult>
</loadResponse>