Skip to content

Refinitiv/libvmod-soap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 :

POST /webservice HTTP/1.1
Host: soapservices.com
Content-Type: text/xml; charset=utf-8

<?xml version="1.0" encoding="utf-8"?>
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Body>
<auth:Login xmlns:auth="http://your/namespace/uri/auth">
    <auth:Username>JohnDoe</auth:Username>
    <auth:Password>foobar</auth:Password>
</auth:Login>
</Body></Envelope>}

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 https://github.com/Refinitiv/libvmod-soap/tree/master/src/tests.

VMOD Interface

is_valid()

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

action()

Returns name of SOAP body's action

action_namespace()

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.

xpath_header(xpath_pattern):

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

xpath_body(xpath_pattern)

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).

Development

If you have installed Varnish to a non-standard directory, call autogen.sh and configure with PKG_CONFIG_PATH pointing to the appropriate path. For example, when varnishd configure was called with --prefix=$PREFIX, use

export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig

Copyright

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

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

About

VMOD Varnish SOAP module. Read SOAP messages in HTTP requests body and expose fields in VCL.

Resources

License

BSD-2-Clause, Unknown licenses found

Licenses found

BSD-2-Clause
LICENSE
Unknown
COPYING

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •