# SOAP / XML web services — Artillery's `soap-with-custom-function`, natively.
#
# loadr sends the raw SOAP envelope as a string body and pulls values back out of
# the XML response with XPath extractors and checks (no custom function needed).
# `local-name()` keeps the XPath namespace-agnostic.
#
#   loadr run examples/42-soap.yaml
name: soap
description: SOAP 1.1 over HTTP — raw XML envelope + XPath extraction & assertions

defaults:
  http:
    base_url: https://soap.example.com

scenarios:
  currency:
    executor: constant-vus
    vus: 5
    duration: 30s
    flow:
      - request:
          name: convert
          method: POST
          url: /CurrencyConvertor.asmx
          headers:
            Content-Type: "text/xml; charset=utf-8"
            SOAPAction: "http://www.webserviceX.NET/ConversionRate"
          body: |
            <?xml version="1.0" encoding="utf-8"?>
            <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
              <soap:Body>
                <ConversionRate xmlns="http://www.webserviceX.NET/">
                  <FromCurrency>USD</FromCurrency>
                  <ToCurrency>GBP</ToCurrency>
                </ConversionRate>
              </soap:Body>
            </soap:Envelope>
          extract:
            - { type: xpath, name: rate, expression: "//*[local-name()='ConversionRateResult']/text()" }
          checks:
            - { type: status, equals: 200 }
            - { type: xpath, expression: "//*[local-name()='ConversionRateResult']", exists: true }

thresholds:
  checks: [ "rate>0.99" ]
  http_req_duration: [ "p(95)<800" ]
