client.lastRequest
, it works perfectly fine. node-soap just returns an empty response
return {
getMetadataResult: {
index: 0,
count: 1,
total: 1,
mediaCollection: {
id: "trending",
itemType: "container",
title: "Trending",
},
mediaCollection: {
id: "new",
itemType: "container",
title: "New",
},
},
};
let client = await soap.createClientAsync(this.environmentUrl, {
ignoreBaseNameSpaces: true,
overrideRootElement: {
namespace: 'fac:',
xmlnsAttributes: [{
name: 'xmlns:fac',
value: "http://www.facturante.com.API"
},{
name: 'xmlns:fac1',
value: "http://schemas.datacontract.org/2004/07/FacturanteMVC.API"
}, {
name: 'xmlns:fac2',
value: "http://schemas.datacontract.org/2004/07/FacturanteMVC.API.DTOs"
}]
},
/*ignoredNamespaces: {
namespaces: ['targetNamespace', 'typedNamespace', 'tns', 'wsu', 'msc', 'i0'],
override: true
}*/
});
client.addHttpHeader('Content-Type', 'application/soap+xml; charset=utf-8');
client.addHttpHeader('Connection', 'Keep-Alive');
let resp = await client.CrearComprobanteAsync({
//'fac:CrearComprobante': {
'fac:request': {
'fac1:Autenticacion': this.parseSecondLevelObj(data.Autenticacion),
'fac1:Cliente': this.parseSecondLevelObj(data.Cliente),
'fac1:Encabezado': this.parseSecondLevelObj(data.Encabezado),
'fac1:Items': [ ...data.Items.map((item, i) => {
return { 'fac2:ComprobanteItem': this.parseSecondLevelObj(item) }
}) ]
}
//}
/*...data,
Items: data.Items.map((item, i) => {
return { ComprobanteItem: {...item} }
})*/
});
I tried to delete the next line too:
client.addHttpHeader('Content-Type', 'application/soap+xml; charset=utf-8');
But the service returns error 415
httpntlm
from the dependencies? We're getting security warnings bc of httpntlm
s dependency underscore
and unfortunately httpntlm
wasn't updated the last 3 years so I don't think they're going to update their package any time soon. Any thoughts on this? Sorry if this has been posted already!
@vpulim
Hi Vinay,
First, thank you for the great job you did with this library. I forked your code to add a test involving a very complex WSDL (WSDLs import, XSD with different namespace, complex types inheritence, etc.) :
stondini/node-soap@533ff7c
I'm not a JavaScript developer so it's hard to figure out the issue but the request seems not to be generated with the correct namespaces.
The request XML is not generated as expect.
Did you already face this kind of issue ?
httpntlm
package was recently merged: SamDecrock/node-http-ntlm#93
Hi Guys, can't seem to get the unit tests running on the project on master with no changes, eg after npm i, then npm run test I get the folllow error:
should allow customization of httpClient and the wsdl file download should pass through it: Uncaught AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:
,
currently running node 16.1.0
Hi James, @allout58 did you solved this issue? cause I am facing the same problem right now. Any one can help please!
Hi, I've got a problem creating the client. I've been able to get it working with another WSDL, but on pointing it to the new WSDL, it crashes with the following stacktrace
TypeError: Cannot read property 'postProcess' of undefined
at subElement.OperationElement.postProcess (C:\Users\jhollowell\WebProjects\swampticket2-backend\node_modules\soap\lib\wsdl.js:651:12)
at subElement.PortTypeElement.postProcess (C:\Users\jhollowell\WebProjects\swampticket2-backend\node_modules\soap\lib\wsdl.js:671:11)
at subElement.BindingElement.postProcess (C:\Users\jhollowell\WebProjects\swampticket2-backend\node_modules\soap\lib\wsdl.js:685:14)
at subElement.ServiceElement.postProcess (C:\Users\jhollowell\WebProjects\swampticket2-backend\node_modules\soap\lib\wsdl.js:721:17)
at C:\Users\jhollowell\WebProjects\swampticket2-backend\node_modules\soap\lib\wsdl.js:1038:26
at WSDL._processNextInclude (C:\Users\jhollowell\WebProjects\swampticket2-backend\node_modules\soap\lib\wsdl.js:1158:12)
at WSDL.processIncludes (C:\Users\jhollowell\WebProjects\swampticket2-backend\node_modules\soap\lib\wsdl.js:1201:8)
at C:\Users\jhollowell\WebProjects\swampticket2-backend\node_modules\soap\lib\wsdl.js:1028:10
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)
at new WSDL (C:\Users\jhollowell\WebProjects\swampticket2-backend\node_modules\soap\lib\wsdl.js:1021:11)
at C:\Users\jhollowell\WebProjects\swampticket2-backend\node_modules\soap\lib\wsdl.js:2246:16
at Request._callback (C:\Users\jhollowell\WebProjects\swampticket2-backend\node_modules\soap\lib\http.js:117:5)
at Request.self.callback (C:\Users\jhollowell\WebProjects\swampticket2-backend\node_modules\request\request.js:188:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request.<anonymous> (C:\Users\jhollowell\WebProjects\swampticket2-backend\node_modules\request\request.js:1171:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at IncomingMessage.<anonymous> (C:\Users\jhollowell\WebProjects\swampticket2-backend\node_modules\request\request.js:1091:12)
at emitNone (events.js:91:20)
at Request.init (C:\Users\jhollowell\WebProjects\swampticket2-backend\node_modules\request\request.js:191:10)
at new Request (C:\Users\jhollowell\WebProjects\swampticket2-backend\node_modules\request\request.js:130:8)
at HttpClient.request [as _request] (C:\Users\jhollowell\WebProjects\swampticket2-backend\node_modules\request\index.js:54:10)
at HttpClient.request (C:\Users\jhollowell\WebProjects\swampticket2-backend\node_modules\soap\lib\http.js:112:18)
at open_wsdl (C:\Users\jhollowell\WebProjects\swampticket2-backend\node_modules\soap\lib\wsdl.js:2242:16)
at C:\Users\jhollowell\WebProjects\swampticket2-backend\node_modules\soap\lib\soap.js:21:7
at _requestWSDL (C:\Users\jhollowell\WebProjects\swampticket2-backend\node_modules\soap\lib\soap.js:47:5)
at createClient (C:\Users\jhollowell\WebProjects\swampticket2-backend\node_modules\soap\lib\soap.js:58:3)
at C:\Users\jhollowell\WebProjects\swampticket2-backend\node_modules\soap\lib\soap.js:68:5
at Promise._execute (C:\Users\jhollowell\WebProjects\swampticket2-backend\node_modules\bluebird\js\release\debuggability.js:303:9)
at Promise._resolveFromExecutor (C:\Users\jhollowell\WebProjects\swampticket2-backend\node_modules\bluebird\js\release\promise.js:483:18)
at new Promise (C:\Users\jhollowell\WebProjects\swampticket2-backend\node_modules\bluebird\js\release\promise.js:79:10)`
const message = {
Header: { ... },
Details: { .... },
attributes: { version: 3.1 },
}
my version attribute is added to the XML without the namespace. What am I doing wrong?
Hi all - noob question here... trying to access a public url ('http://dataaccess.com/webservicesserver/NumberConversion.wso'
) and I've got the following code:
const options = {
wsdl_options: {
forever: true,
rejectUnauthorized: false,
strictSSL: false,
},
wsdl_headers: {
'Content-Type': 'application/json; charset=utf-8',
'Content-Length': 'length'
},
}
let argument = {'ubiNum': '20'}
soap.createClientAsync(url, options)
.then((client) => {
return client.NumberToWords(argument)
})
.then((resp) => {
console.log('hello again', resp)
})
.catch((err) => {
console.log('message', err.message)
return err
})
But I'm getting a 400 error stating Invalid WSDL URL: http://dataaccess.com/webservicesserver/NumberConversion.wso
I was previously getting a 401 error with the same message until I added the quotes to the argument object.
Any advice would be greatly appreciated, I'm pretty stuck :(
Hello all. Brand new to SOAP and a little confused. I'm calling this function on my soap client CreateSecureSession
it should be a POST request. For some reason I think this code is making a GET request based on result.request.method === "GET"
. Is there something I'm missing? Can I force it to run a POST request? The body is html but I expect this function to return a secure session token.
Here is my code
soap.createClient(url, opts, function (err, client) {
console.log("connected")
client.CreateSecureSession(args, function (err, result, rawResponse, soapHeader, rawRequest) {
console.log(JSON.stringify(result, null, 2))
response = result
})
})
hi ! i just install with 'npm install soap' and just execute 'var soap = require('soap');' throw an error: TypeError [ERR_INVALID_ARG_TYPE]: The "original" argument must be of type function
I had the same issue.
It was only a matter of running with a recent node version. Version 9 won't do. But v14 would.
Hi guys,
New to the library, I have created a client with the appropriate URL and args, however, the options I have added are not getting implemented. The server I am trying to call does not work well with soap1.1 and so has to be done with 1.2. Therefore I have added the forceSoap12Headers
tag to true, however looking at the client.last request, the soap XML isn't converted.
Code:
const options: IOptions = {
forceSoap12Headers: true,
};
client.FnName(req, options, function (err, result) {
console.log(client.lastRequest);
});
Generated XML:
<?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="[...]" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/">
<soap:Body>
[well made XML]
</soap:Body>
</soap:Envelope>
Any help would be much appreciated!
"ResponseInfo": {
"attributes": {
"id": "id0",
"soapenc:root": "0",
"soapenv:encodingStyle": "http://schemas.xmlsoap.org/soap/encoding/",
"xsi:type": "ns3:OperationResponseInfo"
},
"response_code": {
"attributes": {
"xsi:type": "xsd:integer"
},
"value": 0
},
"EXTERNAL_SESSION_ID": {
"attributes": {
"xsi:type": "xsd:string"
},
"value": "1212dd0sk"
}
},
Hello Everybody,
How can I make client.Function calls sequentially after receiving response from previous function.
For example:
client.orderlist(args, function(err, response){
console.log(response.ordernumber);
response.forEach(function(arrayResponse){
client.orderinfo(args, function(err, response){
console.log(arrayResponse.emailaddress);
}
}
}
Actual output:
- ordernumber
- ordernumber
- emailaddress
- emailaddress
Expected output:
- ordernumber
- emailaddress
- ordernumber
- emailaddress
Hi. I'm new to node-soap. I have the following issue: A SOAP service is sending me back an XML response with escaped zero bytes (&x0;). Somehow node-soap seems to have problems with that it returns with an Error:
Fault: {
faultcode: 500,
faultstring: 'Invalid XML',
detail: 'Error: Invalid character entity\nLine: 0\nColumn: 19136\nChar: ;',
statusCode: 500
},
Is there a reason why the zero byte is not decoded, but things like CR (\r) or LF (\n) are?
Is it not possible to use
import soap from 'soap';
? When I try to use it that way it comes back undefined, butrequire
seems fine.
I think the package might not have a default export, in that case you would need to import specifically what you want like: import { BearerSecurity, Client, createClient } from 'soap';