Coder Social home page Coder Social logo

wsdlrdr's Introduction

wsdlrdr

a simple wsdl parser, with promises

Support

Buy me a Coffee

how to get

install from npm

npm i wsdlrdr

available methods

getNamespaces

returns a collection with all available namespaces

action description type
response all available namespaces array

getMethodParamsByName

returns all response/request parameter for a given function name

action description type
params methodName string
response methodParams object

getAllFunctions

get all in wsdl available functions as a array

action description type
response all available function names array

getXmlDataAsJson

returns data from the given XML as JSON

action description type
params xml string
response converted xml json

how to use

const Wsdlrdr = require('wsdlrdr');
const params  = { 
	host: 'hostname.com', 
	wsdl: '/path/to/wsdl' 
};

const options = { 
	secure: true // https on
	failOnWrongContentType: true // if no xml/wsdl
}; 

// get all functions listet in wsdl
Wsdlrdr.getAllFunctions(params, options)
.then((funcArray) => { console.log(funcArray); })
.catch((err) => { throw new Error(err) });

wsdlrdr's People

Contributors

daithiw44 avatar dependabot-preview[bot] avatar moszeed avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

wsdlrdr's Issues

Specified Host Port Ignored

My wsdl is hosted by the server at port 8443, but I can only get wsdlrdr to use 443 or 80 depending on the secure flag. Did I miss something or does this only work for wsdl files hosted on those ports? I specified the desired port in the host parameter like this: 10.1.10.100:8443

cacheFileName.replace is not a function

I'm trying to get All namespaces but i get the error below

cacheFileName.replace is not a function","code":141,"level":"error","stack":"Error: cacheFileName.replace is not a function

const wsdlrdr = require('wsdlrdr'); wsdlrdr.getNamespaces(params,{ secure:true}) .then((funcArray) => { console.log("Namespaces are "+funcArray+"\n\n"); }) .catch((err) => { throw new Error(err) });

Don't force Content-type for valid WSDL

An error is thrown in function getWsdl if xml and wsdl are both missing from the Content-type header of a retrieved WSDL document, even if the body is otherwise valid.

Can this be a warning instead? Try to continue ahead with parsing the body so that misconfigured servers (with something silly like text/plain) will not prevent one from consuming the service.

Method to cache WSDL file programmatically

Hi!
I've been working on a testing framework and I'm using wsdlrdr to parse the SOAP API definition in our test project.

I would need a method to store the WSDL in cache programmatically based on promises so I can wait until the document is completely downloaded in cache directory.

I have an approach:

/**
     * Wait for the WSDL content. Checks for the cached file and 
     * if t doesn't exist downloads and stores it in cache folder.
     */
    waitForWsdlReady() {
        return new Promise((resolve) => {
            const params = {
                host: WsConfig.SOAP_HOST,
                path: WsConfig.SOAP_PATH,
                wsdl: WsConfig.SOAP_WSDL,
            };
            const opts = { secure: WsConfig.SOAP_SECURE, failOnWrongContentType: false, };
            wsdlrdr.getCachedWsdl(params, opts)
                .then((wsdl) => {
                    // return cached wsdl if available
                    if (wsdl !== null) {
                        console.log('waitForWsdlReady - Already stored WSDL');
                        resolve(wsdl);
                    }

                    // create a params copy
                    const paramsCopy = Object.assign({}, params, {
                        path: params.wsdl
                    });

                    // refresh wsdl, save to cache
                    return wsdlrdr.doGetRequest(paramsCopy, opts)
                        .then((res) => {
                            if (res.response.statusCode !== 200) {
                                throw new Error(`fail to get wsdl: ${res.response.statusMessage}`);
                            }

                            const contentType = res.response.headers['content-type'];
                            if (contentType.indexOf('xml') === -1 &&
                                contentType.indexOf('wsdl') === -1) {
                                if (opts.failOnWrongContentType === void 0 ||
                                    opts.failOnWrongContentType === true) {
                                    throw new Error('no wsdl/xml response');
                                } else {
                                    console.error('no wsdl/xml as content-type');
                                }
                            }

                            console.log('waitForWsdlReady - Caching WSDL');
                            wsdl.saveWsdlToCache(params, res.body).then(() => {
                                resolve();
                            });
                        });
                });
        });
    }

Notice that I'm not resolving the promise until saveWsdlToCache has ended.

Thank you for providing such as great library. Greetings!

Cache path does not work on lambda

I am using easysoap on lambda to run soap requests. This lib in turn uses wsdlrdr which throws an exception since it tries to create a folder that cannot be changed:

Error: Error: EROFS: read-only file system, mkdir '/cache'

On lambda one is free to use '/tmp' during execution but no other folder. Could this folder path be changed to '/tmp/cache' or something similar.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.