Skip to main content
Version: 9.0

Methods

All web services provide the

execute ( operation, fileContent, fileURL )

method, which can be used to call the corresponding web service’s function.

The definition of the call for the "Converter" web service as an example (excerpt from WSDL):

<xs:complexType name="execute">  
  <xs:sequence>
     <xs:element ref="ns1:operation" minOccurs="0"/>
     <xs:element name="fileContent" xmime:expectedContentTypes="application/octet-stream" type="xs:base64Binary" minOccurs="0"/>
     <xs:element name="fileURL" type="xs:anyURI" minOccurs="0"/>
  </xs:sequence>
</xs:complexType>

The function call uses the following parameters:

operation - Used to define the complex type that contains all the parameters for the web service call (the web service operation). The parameters’ structure conforms to XML schema (XSD) http://schema.webpdf.de/1.0/operation.xsd.

In addition to the "operation," most web services (with the exception of "URLConverter") also expect a document for processing. This document can be specified directly as "fileContent" or as "fileURL."

fileContent - File for which the operation should be executed. The file will be passed in "Base64 encoded" format as a "byte stream" (application/octet-stream).

fileURL - A URL ("file:///”) that points to the document (e.g.: "file:///C:/temp/mydocument.docx")

caution

As of this writing, "fileURL" only supports the "file:" protocol. Other protocols, such as "http://", will result in an error.

The "execute" method will return the "executeResponse" complex type:

<xs:complexType name="executeResponse">  
  <xs:sequence>
  <xs:element name="return" xmime:expectedContentTypes="application/octet-stream" type="xs:base64Binary" nillable="true" minOccurs="0"/>
  </xs:sequence>
</xs:complexType>

The "return" parameter is used to return the modified document as a "Base64 encoded byte stream" (application/octet-stream).

Special feature "URLConverter

For the "URLConverter" web service, only the "operation" parameter is present, since this does not require a document. The URL to be converted is passed in the data structure at "url".

Example with curl

Convert a 10x10 pixel PNG to a PDF document.

curl http://localhost:8080/webPDF/soap/converter \  
 -H 'Content-Type: application/soap+xml;charset=UTF-8' \
 -H 'SOAPAction: "oper:execute"' \
 -d '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:con="http://schema.webpdf.de/1.0/soap/converter" xmlns:oper="http://schema.webpdf.de/1.0/operation">
  <soap:Header/>
  <soap:Body>
     <con:execute>
        <oper:operation>
           <oper:converter pages="*" jpegQuality="90"/>
        </oper:operation>
        <fileContent>iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAFklEQVR42mO88kjuPwMRgHFUIX0VAgCnIhxJzd5DAgAAAABJRU5ErkJggg==</fileContent>
     </con:execute>
  </soap:Body>
</soap:Envelope>'

Via "SOAPAction" the "execute" method of the web service endpoint "/soap/converter" is called, which converts a document into a PDF document. In the "<soap:Envelope ... />" the parameters for the web service are set. The parameters for the "execute" method are set in "<con:execute>...</con:execute>".

Under "<oper:operation>...</oper:operation>" the web service parameters are entered as XML, as e.g. defined for the converter under "Converter Parameter".

Via "<fileContent>...</fileContent>" the document to be converted (10x10 pixel PNG image) is passed encoded as BASE64. Alternatively, the parameter "<fileURL>...</fileURL>" could be used here to reference a file directly (if it is accessible to the server).

The server responds with a "200 OK" after successful conversion and returns the result as an XML message.

< HTTP/1.1 200  
< Content-Type: application/soap+xml;charset=utf-8
...

<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope">
   <S:Body>
       <ns3:executeResponse xmlns:ns3="http://schema.webpdf.de/1.0/soap/converter">
           <return>JVBERi0xLjQKJfbk/ ........ nR4cmVmCjg2MAolJUVPRgo=</return>
       </ns3:executeResponse>
   </S:Body>
</S:Envelope>

The tag "<return>...</return>" contains the created PDF document as BASE64 encoded content.