Trying to send SOAP-request from script (Tests tab).
Script itself:
// Example with a full-fledged request
const PHP = pm.variables.get("PHP")
console.log(PHP)
const postRequest = {
url: PHP+'/my/path',
method: 'POST',
header: {
'Content-Type': 'text/xml;charset=UTF-8',
'Authorization': 'Basic qwertyqwerty'
},
body: {
mode: 'raw',
raw: `<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:api="http://my.org.com/api">
<soapenv:Header/>
<soapenv:Body>
...
</soapenv:Body>
</soapenv:Envelope>`
}
};
pm.sendRequest(postRequest, (error, resp) => {
console.log(resp);
// console.log(error ? error : xml2Json(resp));
});
Snippet works! I can see in console dump of a successful request-response:
POST http://host:port/path
200
162 ms
POST /path HTTP/1.1
Content-Type: text/xml;charset=UTF-8
Authorization: Basic qwertyqwerty
User-Agent: PostmanRuntime/7.26.8
Accept: */*
Postman-Token: b2031eb0-885a-4e28-b136-e02ecfa0ba49
Host: host:port
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 486
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xmlns>
<soapenv:Header/>
<soapenv:Body>
...
</soapenv:Body>
</soapenv:Envelope>
HTTP/1.1 200 OK
X-Powered-By: Servlet/2.5
Server: Sun GlassFish Enterprise Server v2.1.1
Content-Type: text/xml;charset="utf-8"
Transfer-Encoding: chunked
Date: Tue, 08 Dec 2020 10:47:27 GMT
<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body>...</S:Body></S:Envelope>
But this part of a snippet:
pm.sendRequest(postRequest, (error, resp) => {
console.log(resp);
// console.log(error ? error : xml2Json(resp));
});
Returns this:
What am I doing wrong?