javascript js soap.createClientAsync()和wsdl作为字符串

hrirmatl  于 2023-03-16  发布在  Java
关注(0)|答案(1)|浏览(128)

如果我有一个字符串形式的wsdl,如何使用npm soap包在Node.js中创建一个soap客户端?

const soap = require('soap')
const wsdl = '<definitions> ... </definitions>'

const client = await soap.createClientAsync(wsdl) // Wrong: soap thinks that wsdl is a filename

P.S.将wsdl字符串保存到文件中不是一个选项

vshtjzan

vshtjzan1#

我发现您必须添加一个XML头(<?xml version="1.0" encoding="UTF-8"?>)。

const soap = require('soap')

const wsdl = '<definitions> ... </definitions>'
const xml = `<?xml version="1.0" encoding="UTF-8"?>${wsdl}`
const client = await soap.createClientAsync(xml)

相关问题