# SOAP Example
> [HTML Version](soapexample.htm)
_Added June 2013_
SOAP requests may be formed by combining an XML-format document (based on the requirements for the web service as defined in the WSDL for the service) with a set of HTTP binding headers. The technique is essentially the same as described in Customizing POST headers, except that the Content-Type may be different and typically you will be adding a SOAPAction header. The following is a an example of a real web service (as of June 2013) provided by WebserviceX.NET which returns details about airports based on the airport code. The format of the XML request document is as follows:
\$AIRPORTCODE\$
To generate an actual request, we copy the above into a file, replacing the \$AIRPORTCODE\$ with the actual code (see CGIUTL for one technique to simply such replacements). In order to specify the desired Content-Type and the SOAPAction header, we insert it at the top of our file, followed by a blank line and then the XML request:
Content-Type: text/xml; charset=utf-8
SOAPAction: ["http://www.webserviceX.NET/getAirportInformationByAirportCode"](http://www.webserviceX.NET/getAirportInformationByAirportCode)
Assuming that our generated request file is called "airport.req", we can then call the web service as follows:
flags = XHTTPF\_REQPOST \! POST request (typical for SOAP)
flags = flags or XHTTPF\_FILEREQ or XHTTPF\_FILERESP \! request and response are both filespecs
flags = flags or XHTTPF\_HDRBODY \! request body contains header lines
url = ["http://www.webserviceX.NET/airport.asmx"](http://www.webserviceX.NET/airport.asmx)
xcall HTTP, 1, status, flags, url, "airport.req", "airport.rsp"
To examine the final headers as sent to the service, add the XHTTPF\_DEBUG flag and then check the resulting debug.req file, which should look something like:
POST /airport.asmx HTTP/1.1
Host: [www.webservicex.net](http://www.webservicex.net)
Content-Type: text/xml; charset="utf-8"
SOAPAction: ["http://www.webserviceX.NET/getAirportInformationByAirportCode"](http://www.webserviceX.NET/getAirportInformationByAirportCode)
Content-Length: 418
LAX
Note that the POST, Host:, and Content-Length headers are added automatically, but the Content-Type and SOAPAction headers are copied from the request file.
The program [AIRPORT in EXLIB:\[908,25\]](https://bitbucket.org/microsabio/exlib/src/master/908025/airport.bp) demonstrates this service.