An open API service indexing awesome lists of open source software.

https://github.com/refinitiv/libvmod-soap

VMOD Varnish SOAP module. Read SOAP messages in HTTP requests body and expose fields in VCL.
https://github.com/refinitiv/libvmod-soap

Last synced: 10 months ago
JSON representation

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

Awesome Lists containing this project

README

          

libvmod-soap [![Build Status](https://travis-ci.org/Refinitiv/libvmod-soap.svg?branch=master)](https://travis-ci.org/Refinitiv/libvmod-soap)
=============

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 ```` Node.

Usage and Examples
=============
For a given SOAP XML message stored in Request's body :
```xml
POST /webservice HTTP/1.1
Host: soapservices.com
Content-Type: text/xml; charset=utf-8

JohnDoe
foobar

}
```

Select backend accordingly to the value of SOAP action:
```vcl
import soap;
sub vcl_recv {
if(soap.action() == "Login") {
set req.backend_hint = soap_login;
}
}
```

Verify action namespace:
```vcl
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
```vcl
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

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