Although k6 doesn't have any built-in APIs for working with SOAP or XML data in general, you can still easily load test a SOAP-based API by crafting SOAP messages and using the HTTP request APIs.
1import http from 'k6/http';2import { check, sleep } from 'k6';3 4const soapReqBody = `5<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:hs="http://www.holidaywebservice.com/HolidayService_v2/">6 <soapenv:Body>7 <hs:GetHolidaysAvailable>8 <hs:countryCode>UnitedStates</hs:countryCode>9 </hs:GetHolidaysAvailable>10 </soapenv:Body>11</soapenv:Envelope>`;12 13export default function () {14 // When making a SOAP POST request we must not forget to set the content type to text/xml15 const res = http.post(16 'http://www.holidaywebservice.com/HolidayService_v2/HolidayService2.asmx',17 soapReqBody,18 { headers: { 'Content-Type': 'text/xml' } }19 );20 21 // Make sure the response is correct22 check(res, {23 'status is 200': (r) => r.status === 200,24 'black friday is present': (r) => r.body.indexOf('BLACK-FRIDAY') !== -1,25 });26 27 sleep(1);28}