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.
- Host: GitHub
- URL: https://github.com/refinitiv/libvmod-soap
- Owner: Refinitiv
- License: bsd-2-clause
- Created: 2017-02-03T17:54:32.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-06-29T14:06:22.000Z (almost 3 years ago)
- Last Synced: 2025-04-05T01:32:24.317Z (about 1 year ago)
- Language: C
- Size: 130 KB
- Stars: 2
- Watchers: 98
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.rst
- License: COPYING
Awesome Lists containing this project
README
libvmod-soap [](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).