Skip to content
Go to file
Cannot retrieve contributors at this time
107 lines (86 sloc) 2.66 KB

libvmod-soap Build Status

SOAP VMOD compatible with Varnish 4 and 5.

libvmod-soap reads SOAP XML basic elements in HTTP request body (by using action, uri, and/or xpath). It allows users to use VCL with these SOAP values. The action is the application-specific operation. It is defined as the first element in the <Body> Node.

Usage and Examples

For a given SOAP XML message stored in Request's body :

<?xml version="1.0" encoding="utf-8"?>
<Envelope xmlns=""><Body>
<auth:Login xmlns:auth="http://your/namespace/uri/auth">

Select backend accordingly to the value of SOAP action:

import soap;
sub vcl_recv {
    if(soap.action() == "Login") {
        set req.backend_hint = soap_login;

Verify action namespace:

import soap;
sub vcl_recv {
    if(soap.action_namespace() !~ "^http://your/namespace/uri/") {
        return (soap.synth(400, "Bad SOAP namespace"));

Search XPath values and put it into HTTP headers

import soap;
sub vcl_init {
        soap.add_namespace("a", "http://your/namespace/uri/auth");
sub vcl_recv {
        set req.http.user-id = soap.xpath_body("a:Login/a:User");
        set req.http.user-pwd = soap.xpath_body("a:Login/a:Password");

Looking for more ? See other examples on

VMOD Interface


Returns TRUE if the request body is a valid SOAP message.


Returns name of SOAP body's action


Returns namespace of SOAP body's action

add_namespace(prefix, uri)

Add namespace "prefix/uri" into known namespaces. See also xpath_header and xpath_body.


Returns xpath value in SOAP Header. It uses the namespace table (see add_namespace).


Returns xpath value in SOAP Body. It uses the namespace table (see add_namespace).

VOID synthetic(faultcode, faultmessage)

Creates a SOAP synthetic response's body containing SOAP FaultCode and FaultMessage. Note that FaultMessage contains any internal errors found. Format of the response depends of the SOAP version of the request (either 1.1 or 1.2).


This document is licensed under BSD-2-Clause license. See LICENSE for details.

The code was opened by (c) Refinitiv (previously Thomson Reuters).

You can’t perform that action at this time.