XProc steps

A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

p:http-request

<p:declare-step type="p:http-request">
   <p:input port="source"/>
   <p:output port="result"/>
   <p:option name="byte-order-mark"/> <!-- boolean -->
   <p:option name="cdata-section-elements" select="''"/> <!-- ListOfQNames -->
   <p:option name="doctype-public"/> <!-- string -->
   <p:option name="doctype-system"/> <!-- anyURI -->
   <p:option name="encoding"/> <!-- string -->
   <p:option name="escape-uri-attributes" select="'false'"/> <!-- boolean -->
   <p:option name="include-content-type" select="'true'"/> <!-- boolean -->
   <p:option name="indent" select="'false'"/> <!-- boolean -->
   <p:option name="media-type"/> <!-- string -->
   <p:option name="method" select="'xml'"/> <!-- QName -->
   <p:option name="normalization-form" select="'none'"/> <!-- NormalizationForm -->
   <p:option name="omit-xml-declaration" select="'true'"/> <!-- boolean -->
   <p:option name="standalone" select="'omit'"/> <!-- "true" | "false" | "omit" -->
   <p:option name="undeclare-prefixes"/> <!-- boolean -->
   <p:option name="version" select="'1.0'"/> <!-- string -->
</p:declare-step>

With the help of the <p:http-request> step, requests can be sent to web services. Support is given to REST- as well as to SOAP-operated web service implementations. The actual request is also realised via the input port (“source“). All available options are optional and used for the individual configuration of the request. The service request has to be implemented by a <c:request> element, otherwise a dynamic error would occur.

<c:request
   method = NCName
   href? = anyURI
   detailed? = boolean
   status-only? = boolean
   username? = string
   password? = string
   auth-method? = string
   send-authorization? = boolean
   override-content-type? = string>
      (c:header*,
      (c:multipart |
       c:body)?)
</c:request>

Here too, there are various options depending on the type of the request. Relevant is the indication of the transmission method to be used (“POST“ or “GET“) as well as “href“, here the address of the service to be read out is deposited. The other indications are relevant depending on the cases (e.g. for web services which require a login via password etc.) and will not be further discussed here.

Example

In the following example the RSS feed of the website "http://www.imdb.com" is read out.

<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" xmlns:c="http://www.w3.org/ns/xproc-step" version="1.0">
   <p:input port="source">
      <p:inline>
         <c:request method="GET" href="http://rss.imdb.com/news/"/>
      </p:inline>
   </p:input>
   <p:output port="result"/>
   <p:http-request/>
</p:declare-step>