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

wcf.js

v0.0.6

Published

A WCF-compatible web services client stack for node.js

Downloads

1,217

Readme

WCF.JS

A WCF-compatible web service client stack for node.js. Written in pure javascript!

Imagine this:

var binding = new WSHttpBinding(
      { MessageEncoding: "Mtom"
      , SecurityMode:"TransportWithMessageCredential"
      })
  , proxy = new Proxy(binding)      

proxy.ClientCredentials.Username.Username = "yaron";
proxy.ClientCredentials.Username.Password = "1234";

proxy.send(message, function(response) {
  console.log(response)
});

(See below for a complete sample)

Currently supports a subset of:

  • BasicHttpBinding
  • WSHttpBinding
  • CustomBinding

The current subset includes:

  • MTOM / Text encodings
  • WS-Addressing (all versions)
  • Transport Security (SSL)
  • Transport with message credential (Username)

For more information visit my wcf blog.

Install

Install with npm:

npm install wcf.js

Usage

BasicHttpBinding (TransportWithMessageCredential)

var BasicHttpBinding = require('wcf.js').BasicHttpBinding
  , Proxy = require('wcf.js').Proxy
  , binding = new BasicHttpBinding(
        { SecurityMode: "TransportWithMessageCredential"
        , MessageClientCredentialType: "UserName"
        })
  , proxy = new Proxy(binding, "http://localhost:7171/Service/clearUsername")
  , message =  "<Envelope xmlns='http://schemas.xmlsoap.org/soap/envelope/'>" +
                 "<Header />" +
                   "<Body>" +
                     "<GetData xmlns='http://tempuri.org/'>" +
                       "<value>123</value>" +
                     "</GetData>" +
                    "</Body>" +
               "</Envelope>";

proxy.ClientCredentials.Username.Username = "yaron";
proxy.ClientCredentials.Username.Password = "1234";

proxy.send(message, "http://tempuri.org/IService/GetData", function(response, ctx) {
  console.log(response)
});

CustomBinding (Mtom + UserNameOverTransport + WSAddressing10)

var CustomBinding = require('wcf.js').CustomBinding
  , MtomMessageEncodingBindingElement = require('wcf.js').MtomMessageEncodingBindingElement
  , HttpTransportBindingElement = require('wcf.js').HttpTransportBindingElement
  , SecurityBindingElement = require('./lib/proxies/wcf.js').SecurityBindingElement
  , Proxy = require('wcf.js').Proxy
  , fs = require('fs')
  , binding = new CustomBinding(
        [ new SecurityBindingElement({AuthenticationMode: "UserNameOverTransport"})
        , new MtomMessageEncodingBindingElement({MessageVersion: "Soap12WSAddressing10"}),
        , new HttpTransportBindingElement()
        ])
  , proxy = new Proxy(binding, "http://localhost:7171/Service/mtom")
  , message = '<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">' +
                '<s:Header />' +
                  '<s:Body>' +
                    '<EchoFiles xmlns="http://tempuri.org/">' +
                      '<value xmlns:a="http://schemas.datacontract.org/2004/07/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">' +
                        '<a:File1 />' +
                        '<a:File2 />' +
                      '</value>' +
                    '</EchoFiles>' +
                  '</s:Body>' +
              '</s:Envelope>'  

proxy.addAttachment("//*[local-name(.)='File1']", "me.jpg");
proxy.addAttachment("//*[local-name(.)='File2']", "stuff.txt");

proxy.ClientCredentials.Username.Username = "yaron";
proxy.ClientCredentials.Username.Password = "1234";

proxy.send(message, "http://tempuri.org/IService/EchoFiles", function(response, ctx) {
  console.log(response);
  //read an mtom attachment from the soap response
  var file = proxy.getAttachment("//*[local-name(.)='File1']")
  fs.writeFileSync("result.jpg", file)      
});