client.setSecurity(new soap.NTLMSecurity(credentials));
but right now i have doubts that this is the only thing i have to do. My ntlm user - which is working via soapui/postman - got immediately blocked on first request, cause as the sys admin said, 10 failed authentications have been catched. Should it work out of the box on a linux docker instance? Do i need CNTLM or a windows server image?
const soap = require("soap");
(async () => {
const client = await soap.createClientAsync("http://www.dneonline.com/calculator.asmx?wsdl");
try {
const res = await client.AddAsync ({
"intA": "1",
"intB": "a"
});
console.log(res[0]?.AddResult);
} catch (error) {
console.log("ERROR:", error?.message);
}
}) ();
C:> npm install soap@0.40.0
C:> node .\soap.js
ERROR: Request failed with status code 500
C:> npm install soap@0.39.0
C:> node .\soap.js
ERROR: soap:Client: System.Web.Services.Protocols.SoapException: Server was unable to read request. ---> System.InvalidOperationException: There is an error in XML document (1, 326). ---> System.FormatException: Input string was not in a correct format.
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at System.Xml.XmlConvert.ToInt32(String s)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read1_Add()
at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer.Deserialize(XmlSerializationReader reader)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
I have the following error in my log:
2021-08-25T08:13:59.074-03:00 Error: Error http status codes
2021-08-25T08:13:59.074-03:00 at finish (/appserver/server/node_modules/soap/lib/client.js:256:33)
2021-08-25T08:13:59.074-03:00 at parseSync (/appserver/server/node_modules/soap/lib/client.js:307:20)
2021-08-25T08:13:59.074-03:00 at /appserver/server/node_modules/soap/lib/client.js:466:24
2021-08-25T08:13:59.074-03:00 at Request._callback (/appserver/server/node_modules/soap/lib/http.js:171:17)
2021-08-25T08:13:59.074-03:00 at Request.self.callback (/appserver/server/node_modules/request/request.js:185:22)
2021-08-25T08:13:59.074-03:00 at Request.emit (events.js:314:20)
2021-08-25T08:13:59.074-03:00 at Request.EventEmitter.emit (domain.js:483:12)
2021-08-25T08:13:59.074-03:00 at Request.<anonymous> (/appserver/server/node_modules/request/request.js:1154:10)
2021-08-25T08:13:59.074-03:00 at Request.emit (events.js:314:20)
2021-08-25T08:13:59.074-03:00 at Request.EventEmitter.emit (domain.js:483:12)
Which can cause the error: "Error http status codes"?
Thanks!
Hi people ! client.setSecurity using NTLMSecurity doesn't seems to work.
I've tested my authentication using SOAPUI and it's going fine.
Writing these code result each time in a 401 Unauthorized response from my WS. (My .wsdl file is correct and here)
soap.createClient("file.wsdl", (err, client) => {
client.setSecurity(new soap.NTLMSecurity(username, password, domain))
client.MyFunction({}, (err, result) => {
if (err) {
console.log(err.response.status)
}
res.json(result)
})
})
No Authorization Headers are set to my HTTP Request this way, I think that's the problem because using an old library "soap-ntlm" https://github.com/piotr-gawlowski/node-soap, there are Headers. Any ideas ?
https-proxy-agent
package to send requests via a http proxy, the code works with proxy in version 0.39.0 but not latest (I am not testing 0.41.0 but I think the issue is here)
Hi all, I upgraded from v 0.37.0 to 0.40.0 and I noticed a change in how errors are returned.
I'm using a WSDL instance and the same request with 0.37.0 returns an error like this:
{
"root":{
"Envelope":{
"Body":{
"Fault":{
"faultcode":"soap:Server",
"faultstring":"Il codice fiscale non e' nel formato corretto di 16 caratteri",
"detail":{
"WSException":{
"error":"3",
"message":"Il codice fiscale non e' nel formato corretto di 16 caratteri"
}
}
}
}
}
}
}
With 0.40.0 I get this (I replaced some informations with ...):
{
"message":"Request failed with status code 500",
"name":"Error",
"stack":"Error: Request failed with status code 500\n at createError (/usr/local/src/liveid/api/node_modules/axios/lib/core/createError.js:16:15)\n at settle (/usr/local/src/liveid/api/node_modules/axios/lib/core/settle.js:17:12)\n at IncomingMessage.handleStreamEnd (/usr/local/src/liveid/api/node_modules/axios/lib/adapters/http.js:260:11)\n at IncomingMessage.emit (events.js:326:22)\n at IncomingMessage.EventEmitter.emit (domain.js:483:12)\n at endReadableNT (_stream_readable.js:1241:12)\n at /usr/local/src/liveid/api/node_modules/async-listener/glue.js:188:31\n at processTicksAndRejections (internal/process/task_queues.js:84:21)",
"config":{
"url": ...,
"method":"post",
"data":"<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:tns=\"http://service.ws.nam/\">...</soap:Envelope>",
"headers":{
"Accept":"text/html,application/xhtml+xml,application/xml,text/xml;q=0.9,*/*;q=0.8",
"Content-Type":"text/xml; charset=utf-8",
"User-Agent":"node-soap/0.40.0",
"Accept-Encoding":"none",
"Accept-Charset":"utf-8",
"Connection":"close",
"Host": ...,
"Content-Length":1529,
"SOAPAction":"\"\"",
"Authorization":"Basic ..."
},
"transformRequest":[
null
],
"transformResponse":[
null
],
"timeout":0,
"xsrfCookieName":"XSRF-TOKEN",
"xsrfHeaderName":"X-XSRF-TOKEN",
"maxContentLength":-1,
"maxBodyLength":-1
}
}
Does anybody have some ideas of why this happens and how to restore an error like the one I get with 0.37.0 (beside from downgrading to 0.37.0 :P)?
hello i recently started working on soap request because of a requirement in our org.
var soap = require('soap');
var url = 'http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso';
var args = {sCountryISOCode: 'IN'};
soap.createClient(url, function(err, client) {
client.MyFunction(args, function(err, result) {
console.log(result);
});
});
i used that endpoint for testing purposes, which returns the capital of any country
I am not sure what will go in the args,
I made the same request from postman as you can see in the image
with the library i get this error
TypeError: Cannot read property 'MyFunction' of undefined
Hello group
How could I overwrite the request to inform the certificate before creating the client?
The server that has the WSDL requests mutual authentication by certificate
const options : any = {
url: `${url}`,
cert: Buffer.from(this.cert, 'utf8'),
key: Buffer.from(this.key, 'utf8'),
};
//const req = request.defaults(options);
const req = request.defaults(options);
return soap.createClient(`${url}`, {request: req}, (err: any, client: any) => {
});
But I got an error:
error -> TypeError: req.then is not a function
at HttpClient.request (C:\Users\marco\git\facturacionelectronicapy-setapi\node_modules\soap\src\http.ts:184:9)
at Object.open_wsdl (C:\Users\marco\git\facturacionelectronicapy-setapi\node_modules\soap\src\wsdl\index.ts:1414:16)
at openWsdl (C:\Users\marco\git\facturacionelectronicapy-setapi\node_modules\soap\src\soap.ts:55:5)
at C:\Users\marco\git\facturacionelectronicapy-setapi\node_modules\soap\src\soap.ts:32:7
at _requestWSDL (C:\Users\marco\git\facturacionelectronicapy-setapi\node_modules\soap\src\soap.ts:61:5)
at Object.createClient (C:\Users\marco\git\facturacionelectronicapy-setapi\node_modules\soap\src\soap.ts:83:3)
Thanks
<soap:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="_30d88595-86e5-446e-b779-60b13612fe62">
<xenc:EncryptedData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" Id="ED-9cacd30b-e921-4f12-b13c-66618fd704b3" Type="http://www.w3.org/2001/04/xmlenc#Content">
<xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc" />
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<wsse:SecurityTokenReference xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsse11="http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd" wsse11:TokenType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKey">
<wsse:Reference URI="#EK-e9aa9c0a-28cf-487a-81e9-a38f1e4079db" />
</wsse:SecurityTokenReference>
</ds:KeyInfo>
<xenc:CipherData>
<xenc:CipherValue>ghu/wEcFEkun4tImo++HWo3rpXU9jPw9qSA/uGhrqqAAR/LuE+6G8aFPNZ/QLDnocxvfAicieWoTlmJ5kpitjmJHW3lv95PKPyMoE/GymNVicG6qCp/HARBbk0uY+SkkSS91n7AOyGARO80aa4npggbUFdzaZlywKOMFZ6tSTDC/+0YZAfQTjecSm3xSl5C3zFX5fPgvXuVRT4AEeFnjwvja2lbJFOLc2Vhpd0tG3LGkKA111q99Qkt/o3S7/GUfimbZKQhInXioCw+t73PpKPu0JtG5YOdCuHBoJJUhW/T6DKcYdFx0exWxz7EFfa2RMK5emB9bJplPKS4fflMDpA==</xenc:CipherValue>
</xenc:CipherData>
</xenc:EncryptedData>
</soap:Body>
Hey everyone I am trying to create a soap server in my local that listens on https.
let key = fs.readFileSync('key.pem');
let cert = fs.readFileSync('cert.pem')
let soapServer = soap.listen(httpServer, {
path: urlPath,
services: processorService,
xml: xmlPath,
key : key,
cert : cert
});
When i am trying to make a request, I am always getting secure connection could not be established error. I have all the WSDL files and the server works properly without https ( i.e http ) .
Any pointers to help ?
hi everyone, does anybody have experience with using async with postProcess option?
i need to modify XML in postProcess, but first need to pull it through async method. postProcess just goes on without waiting.
example:postProcess: async (_xml) => {
_xml = await someMethod(_xml);
return _xml;
}
Hi! I'm getting the following error when trying to use an async client with ts-node
(node:21227) UnhandledPromiseRejectionWarning: Error: soapenv:server: java.lang.NullPointerException: {"message":null}
at finish (/Users/verner/Code/equifax/node_modules/soap/src/wsdl/index.ts:513:30)
at WSDL.xmlToObject (/Users/verner/Code/equifax/node_modules/soap/src/wsdl/index.ts:491:12)
at parseSync (/Users/verner/Code/equifax/node_modules/soap/src/client.ts:362:25)
at /Users/verner/Code/equifax/node_modules/soap/src/client.ts:575:16
at /Users/verner/Code/equifax/node_modules/soap/src/http.ts:214:7
at processTicksAndRejections (internal/process/task_queues.js:95:5)
Any ideas what could be wrong?
:point_up: Edit: Hello guys, I have updated my soap to 0.43 hence I have replaced the options.request in createClient by axiosInstance..
Below is my old code snippet =>
request.defaults({
strictSSL: true,
ca: caCert
});
and the new implementation using axios->
axiosInstance.defaults.httpsAgent = new https.Agent({
rejectUnauthorized: true,
ca: cacert
});
My options for soap.CreateClient ->
Options = {
url,
wsdl_options: {
rejectUnauthorized: true,
pfx,
passphrase,
strictSSL: true,
},
request:axiosInstance
}.
I get below error "Invalid WSDL 401 error".. Am I missing any paramter?
:point_up: Edit: Hello guys, I have updated my soap to 0.43 hence I have replaced the options.request in createClient by axiosInstance..
Below is my old code snippet =>
request.defaults({
strictSSL: true,
ca: caCert
});
and the new implementation using axios->
axiosInstance.defaults.httpsAgent = new https.Agent({
rejectUnauthorized: true,
ca: cacert
});
My options for soap.CreateClient ->
Options = {
url,
wsdl_options: {
rejectUnauthorized: true,
pfx,
passphrase,
strictSSL: true,
},
request:axiosInstance
}.
I get below error "Invalid WSDL 401 error".. Am I missing any paramter?
Code: 401
Response Body: <html><head><meta http-equiv="content-type" content="text/html; charset=windows-1252"><title>Anmeldung fehlgeschlagen