diff --git a/README.md b/README.md new file mode 100644 index 0000000..611258d --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# jQuery.SOAPUI: A SwaggerUI but for SOAP Services + +## Description + +This jQuery module spins up a web interface over the +[jquery.soap](https://github.com/doedje/jquery.soap) plugin in order to +try a SOAP Web Service directly from your web browser. + +This module has only one major pre-requisite: the SOAP service has to be exposed +through an API Gateway the supports CORS. +Hopefully, [apicast](https://github.com/3scale/apicast) does ! + +It is intended to be used in the 3scale developer portal. diff --git a/index.html b/index.html new file mode 100644 index 0000000..287f125 --- /dev/null +++ b/index.html @@ -0,0 +1,75 @@ + + + + + + SOAPUI test page + + + + + + + + +

Get information about Spain

+
+ + +
+ +

Get information about Poland

+
+ + +
+ +

Get information about funny country

+
+ + +
+ + diff --git a/soapui.js b/soapui.js new file mode 100644 index 0000000..4e16e89 --- /dev/null +++ b/soapui.js @@ -0,0 +1,138 @@ +/* + * soapui.js - https://github.com/nmasse-itix/soapui + * version: 0.1 + * + * jQuery plugin to handle the "try it out" feature for SOAP Services + * + * License MIT + * ----------------- + * The MIT License (MIT) + * + * Copyright (c) 2016 Nicolas MASSE + * + * 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. + * + * Information + * ----------- + * + * For information about how to use soapui, authors, changelog, the latest version, etc... + * Visit: https://github.com/nmasse-itix/soapui + */ + +(function(factory) { + if(typeof module === 'object' && typeof module.exports === 'object') { + module.exports = factory(require('jquery')); + } else if (jQuery) { + factory(jQuery); + } else { + console.error('no jQuery found!') + } +})(function($) { + function soapui(root_node, soap_options) { + root_node = $(root_node); // Make sure it is a jQuery object + + // Detect if vkbeautify is loaded + var vkbeautify = window.vkbeautify; + if (vkbeautify == null) { + console.log("vkbeautify not loaded, using a poor replacement for XML Pretty Printing"); + vkbeautify = { xml: function (xml) { + // Poor man XML pretty printing + return xml.replace(/(>)|([^>])(?=<)/g, "$1$2\n"); + } } + } + + // SOAP request section + var soapActionNode = $(root_node).find("soap-action").get(0); + soapActionNode = soapActionNode != null ? $(soapActionNode) : null; + var soapAction = soapActionNode != null ? soapActionNode.text() : null; + if (soapAction != null && soapAction != "") { + soapActionNode.before("SOAP Action"); + soapActionNode.replaceWith(function (i, e) { + return $("", { value: soapAction, type: "text"}); + }); + } else { + soapActionNode.find("soap-action") + .remove(); + } + + var soapBodyNode = root_node.find("soap-body") + .contents() + .filter(function() { + return this.nodeType == Node.COMMENT_NODE; + }) + .get(0); + var soapBody = soapBodyNode != null ? soapBodyNode.data : ""; + var newSoapBodyNode = $("