Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readme updates, cleanup of Examples & code #19

Merged
merged 11 commits into from
Sep 27, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixed PR review comments
rashmihunt committed Sep 27, 2016
commit edbf0ac6970c77297e66f5ebbdcf365efb2e5377
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Copyright (c) IBM Corp. 2011,2016. All Rights Reserved.
Node module: loopback-datasource-juggler
Copyright (c) IBM Corp. 2016. All Rights Reserved.
Node module: strong-soap
This project is licensed under the MIT License, full text below.

--------
23 changes: 23 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
This product includes software developed at https://github.com/vpulim/node-soap
under the following MIT license.

Copyright (C) 2013 Vinay Pulim

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

102 changes: 66 additions & 36 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ This module provides SOAP client for invoking Web Services. It also provides a m
- [Features:](#features)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the trailing :.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed review comments.. @raymondfeng PTAL

- [Install](#install)
- [Client](#client)
- [XMLHandler](#XMLHandler)
- [Client.describe() - description of services, ports and methods as a JavaScript object](#clientdescribe---description-of-services-ports-and-methods-as-a-javascript-object)
- [Client.setSecurity(security) - use the specified security protocol](#clientsetsecuritysecurity---use-the-specified-security-protocol)
- [Client.*method*(args, callback) - call *method* on the SOAP service.](#clientmethodargs-callback---call-method-on-the-soap-service)
@@ -31,6 +30,8 @@ This module provides SOAP client for invoking Web Services. It also provides a m
- [Outgoing SOAP Headers](#outgoing-soap-headers)
- [Handling XML Attributes, Value and XML (wsdlOptions).](#handling-xml-attributes-value-and-xml-wsdloptions)
- [Specifying the exact namespace definition of the root element](#specifying-the-exact-namespace-definition-of-the-root-element)
- [XMLHandler](#XMLHandler)
- [WSDL](#WSDL)
- [Server](#server)
- [soap.listen(*server*, *path*, *services*, *wsdl*) - create a new SOAP server that listens on *path* and provides *services*.](#soaplistenserver-path-services-wsdl---create-a-new-soap-server-that-listens-on-path-and-provides-services)
- [Options](#options)
@@ -112,41 +113,6 @@ The `options` argument allows you to customize the client with the following pro

Note: for versions of node >0.10.X, you may need to specify `{connection: 'keep-alive'}` in SOAP headers to avoid truncation of longer chunked responses.

### XMLHandler
XMLHandler provides capabilities for the user to convert JSON object to XML and XML to JSON object. It also provides capability to Parse XML string or stream into the XMLBuilder tree.

- API to Convert JSON object to XML and XML to JSON object.

```
var soap = require('..').soap;
var XMLHandler = soap.XMLHandler;
var xmlHandler = new XMLHandler();
var util = require('util');

//custom request header
var customRequestHeader = {customheader1: 'test1'};
var options = {};
client.GetCityWeatherByZIP(requestArgs, function(err, result, envelope, soapHeader) {
//convert 'result' JSON object to XML
var node = xmlHandler.jsonToXml(null, null,
XMLHandler.createSOAPEnvelopeDescriptor('soap'), result);
var xml = node.end({pretty: true});
console.log(xml);

//convert XML to JSON object
var root = xmlHandler.xmlToJson(null, xml, null);
console.log('%s', util.inspect(root, {depth: null}));

}, options, customRequestHeader);
});
```

- Parse XML string or stream into the XMLBuilder tree

```
var root = XMLHandler.parseXml(null, xmlString);
```


### Extra Headers (optional)

@@ -454,6 +420,70 @@ soap.createClient(__dirname + '/wsdl/default_namespace.wsdl', wsdlOptions, funct

To see it in practice, consider the sample in: [test/request-response-samples/addPets__force_namespaces](https://github.com/strongloop/strong-soap/tree/master/test/request-response-samples/addPets__force_namespaces)

## XMLHandler
XMLHandler provides capabilities for the user to convert JSON object to XML and XML to JSON object. It also provides capability to Parse XML string or stream into the XMLBuilder tree.

- API to Convert JSON object to XML and XML to JSON object.

```
var soap = require('..').soap;
var XMLHandler = soap.XMLHandler;
var xmlHandler = new XMLHandler();
var util = require('util');

//custom request header
var customRequestHeader = {customheader1: 'test1'};
var options = {};
client.GetCityWeatherByZIP(requestArgs, function(err, result, envelope, soapHeader) {
//convert 'result' JSON object to XML
var node = xmlHandler.jsonToXml(null, null,
XMLHandler.createSOAPEnvelopeDescriptor('soap'), result);
var xml = node.end({pretty: true});
console.log(xml);

//convert XML to JSON object
var root = xmlHandler.xmlToJson(null, xml, null);
console.log('%s', util.inspect(root, {depth: null}));

}, options, customRequestHeader);
});
```

- Parse XML string or stream into the XMLBuilder tree

```
var root = XMLHandler.parseXml(null, xmlString);
```

## WSDL
### wsdl.open(wsdlURL, options, callback(err, wsdl))
API to load WSDL into a tree form. User can traverse through WSDL tree to get to bindings, services, ports, operations etc.
##### Parameters
- `wsdlURL` WSDL url to load.
- `options` WSDL options
- `callback` Error and WSDL loaded into object tree.

```
var soap = require('..').soap;
var WSDL = soap.WSDL;
var path = require('path');

//pass in WSDL options if any

var options = {};
WSDL.open('./wsdls/weather.wsdl',options,
function(err, wsdl) {
//user should be able to get to any information of this WSDL from this object. User can traverse
//the WSDL tree and get to bindings, operations, services, portTypes, messages, parts and XSD elements/Attributes.

var getCityForecastOp = wsdl.definitions.bindings.WeatherSoap.operations.GetCityForecastByZIP;
//print operation name
console.log(getCityForecastOp.name);
var service = wsdl.definitions.services['Weather'];
print service name
console.log(service.name);;
});
```

## Server

20 changes: 13 additions & 7 deletions example/xsds.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
var soap = require('..').soap;
var WSDL = soap.WSDL;
var path = require('path');

WSDL.loadSystemSchemas(function(err, schemas) {
if (err) {
console.error(err);
} else {
console.log(Object.keys(schemas));
}
});

//user can pass in WSDL options
var options = {};

WSDL.open('./wsdls/weather.wsdl', options,
//User can traverse the WSDL tree and get to bindings - > operations, services, portTypes, messages, parts and XSD elements/Attributes
function(err, wsdl) {
var getCityForecastOp = wsdl.definitions.bindings.WeatherSoap.operations.GetCityForecastByZIP;
console.log(getCityForecastOp.name);
var service = wsdl.definitions.services['Weather'];
console.log(service.name);;
});