npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-soap-ly

v0.1.1

Published

A minimal node SOAP client

Downloads

2

Readme

This module lets you connect to web services using SOAP. It also provides a server that allows you to run your own SOAP services.

Current limitations:

  • Only a few XSD Schema types are supported
  • Only WS-Security is supported using UsernameToken and PasswordText encoding

Update of kaven276's node-soap from milewise's node-soap

can parse multiRef request, use=encoding support

Soap request can use multiRef to mapping language's object model to xml, now node-soap can parse the request and mapping it to a javascript object that use object reference as multiRef.

Fiber integration, support async javascript service

For soap server, it has javascript service defined, when node-soap received and parse the soap request, it will route to call the javascript service function, and it will take the return value to convert to response soap xml. But the javascript service function may need to call some other file/network async functions to get the final return value, but node-soap will not wait for it, it just synchronously call and get return value. But this version integrate Fiber to support async service.

var SoapServices = {
    'ESyncNotifySPServiceService': {
        'ESyncNotifySP': {
            'eOrderRelationUpdateNotify': function(args) {
                var fiber = Fiber.current;
                var oraReqNV = args["eOrderRelationUpdateNotifyRequest"];
                Request({
                    uri: cfg.psp_url + '.e',
                    method: 'post',
                    headers: {
                        'Content-Type': "application/x-www-form-urlencoded"
                    },
                    body: QueryString.stringify(oraReqNV)
                },
                function(error, response, body) {
                    if (!error && response.statusCode === 200) {
                        fiber.run({
                            'eOrderRelationUpdateNotifyResponse': {
                                'RecordSequenceID': oraReqNV.RecordSequenceID,
                                'ResultCode': body
                            }
                        });
                    } else {
                        fiber.run({
                            'eOrderRelationUpdateNotifyResponse': {
                                'RecordSequenceID': oraReqNV.RecordSequenceID,
                                'ResultCode': 1
                            }
                        });
                    }
                });
                return yield();
            }
        }
    }
}

correct method routing

How to determine the javascript service method? Firstly, use wsdl:service->wsdl:port->wsdlsoap:address.location to determine what binding/portType to use, Secondly, if style=RPC, then treat top element's name under soap body as the portType's method name, if style=RPC, then use http header SOAPAction to match the operation's soapAction, if there is no http header SOAPAction or no soapAction defined in wsdl, then check every method's input message's element name to find the match.

support both RPC/Document style request/response

xml namespace support

For WSDL parsing, different schema definitions will go into their respective schema parsed javascript objects, it allow the same named types/complexTypes/elements/... in different schemas. Formerly, different schema object with same name will just override and keep the last one, it's totally namespace ignorant and has potential serious problems.

For soap xml generation, the soap envelope has all the xmlns definition(exception for wsdl/soap itself related) defined in the wsdl that not only bring from the wsdl definition element, but from all of the wsdl and its import/include subs. But notice that if a xmlns defined in wsdl's element is conflict with definition element's xmlns map, it may have problems, but it's very rare case.

The soap request by client or response by server will give top element in soap:body a xml namespace prefix that is defined in envelope. And your javascript object for xml can have object attribute with xml namespace prefix, so the result xml payload will have the same namespace prefix. This way, you can use your javascript to make the right namespaced soap xml.

generate minimum of parsed javascript definition object

For the standard parsed format, remove any child/children when the child or child's useful information is attached to the parent's properties, remove fixed attribute of WSDL xml node, remove parent properties so there is no circular reference. The result is a clean and more clear parsed definition object.

Install

Install with npm:

npm install soap

Module

soap.createClient(url, callback) - create a new SOAP client from a WSDL url

var soap = require('soap');
var url = 'http://example.com/wsdl?wsdl';
var args = {name: 'value'};
soap.createClient(url, function(err, client) {
    client.MyFunction(args, function(err, result) {
        console.log(result);
    });
});

soap.listen(server, path, services, wsdl) - create a new SOAP server that listens on path and provides services. wsdl is an xml string that defines the service.

var myService = { 
    MyService: { 
        MyPort: { 
            MyFunction: function(args) {
                return {
                    name: args.name
                };
            }
        }
    }
}

var xml = require('fs').readFileSync('myservice.wsdl', 'utf8'),
    server = http.createServer(function(request,response) {
        response.end("404: Not Found: "+request.url)
    });
    
server.listen(8000);
soap.listen(server, '/wsdl', myService, xml);

Client

An instance of Client is passed to the soap.createClient callback. It is used to execute methods on the soap service.

Client.describe() - description of services, ports and methods as a JavaScript object

client.describe() => 
    { MyService: {
        MyPort: {
            MyFunction: {
                input: {
                    name: 'string'
                }
            }}}}

Client.setSecurity(security) - use the specified security protocol (see WSSecurity below)

client.setSecurity(new WSSecurity('username', 'password'))

Client.method(args, callback) - call method on the SOAP service.

client.MyFunction({name: 'value'}, function(err, result) {
    // result is a javascript object        
})

Client.service.port.method(args, callback) - call a method using a specific service and port

client.MyService.MyPort.MyFunction({name: 'value'}, function(err, result) {
    // result is a javascript object                
})

WSSecurity

WSSecurity implements WS-Security. Currently, only UsernameToken and PasswordText is supported. An instance of WSSecurity is passed to Client.setSecurity.

new WSSecurity(username, password)