Browse Source

convert tabs to spaces

master
Nicolas Massé 8 years ago
parent
commit
aadbda3647
  1. 108
      index.html
  2. 162
      soapui.js

108
index.html

@ -1,75 +1,75 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>SOAPUI test page</title>
<script type='text/javascript' src='https://code.jquery.com/jquery-3.1.1.js'></script>
<script type='text/javascript' src='jquery.soap/jquery.soap.js'></script>
<script type='text/javascript' src='vkBeautify/vkbeautify.js'></script>
<script type='text/javascript' src='soapui.js'></script>
<script type='text/javascript'>
$(document).ready(function() {
$(".soapui").each(function (i, e) {
$.soapui(e, {
url: 'http://api.acme.test/ws',
HTTPHeaders: { "user-key": "<your user-key here>" },
enableLogging: true,
appendMethodToURL: false
});
});
});
</script>
<style>
.soapui span {
font-weight: bold;
}
<head>
<meta charset="UTF-8">
<title>SOAPUI test page</title>
<script type='text/javascript' src='https://code.jquery.com/jquery-3.1.1.js'></script>
<script type='text/javascript' src='jquery.soap/jquery.soap.js'></script>
<script type='text/javascript' src='vkBeautify/vkbeautify.js'></script>
<script type='text/javascript' src='soapui.js'></script>
<script type='text/javascript'>
$(document).ready(function() {
$(".soapui").each(function (i, e) {
$.soapui(e, {
url: 'http://api.acme.test/ws',
HTTPHeaders: { "user-key": "<your user-key here>" },
enableLogging: true,
appendMethodToURL: false
});
});
});
</script>
<style>
.soapui span {
font-weight: bold;
}
.soapui textarea {
width: 80%;
display: block;
height: 200px;
}
.soapui textarea {
width: 80%;
display: block;
height: 200px;
}
.soapui input[type=text] {
width: 80%;
display: block;
}
.soapui input[type=text] {
width: 80%;
display: block;
}
.soapui .hidden {
display: none;
}
</style>
</head>
<body>
<h1>Get information about Spain</h1>
<div class="soapui">
<soap-action></soap-action>
<soap-body><!--
.soapui .hidden {
display: none;
}
</style>
</head>
<body>
<h1>Get information about Spain</h1>
<div class="soapui">
<soap-action></soap-action>
<soap-body><!--
<gs:getCountryRequest xmlns:gs="http://spring.io/guides/gs-producing-web-service">
<gs:name>Spain</gs:name>
</gs:getCountryRequest>
--></soap-body>
</div>
</div>
<h1>Get information about Poland</h1>
<div class="soapui">
<soap-action></soap-action>
<soap-body><!--
<h1>Get information about Poland</h1>
<div class="soapui">
<soap-action></soap-action>
<soap-body><!--
<gs:getCountryRequest xmlns:gs="http://spring.io/guides/gs-producing-web-service">
<gs:name>Poland</gs:name>
</gs:getCountryRequest>
--></soap-body>
</div>
</div>
<h1>Get information about funny country</h1>
<div class="soapui">
<soap-action></soap-action>
<soap-body><!--
<h1>Get information about funny country</h1>
<div class="soapui">
<soap-action></soap-action>
<soap-body><!--
<gs:getCountryRequest xmlns:gs="http://spring.io/guides/gs-producing-web-service">
<gs:name>The Moon</gs:name>
</gs:getCountryRequest>
--></soap-body>
</div>
</body>
</div>
</body>
</html>

162
soapui.js

@ -36,102 +36,102 @@
*/
(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!')
}
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
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");
} }
}
// 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("<span>SOAP Action</span>");
soapActionNode.replaceWith(function (i, e) {
return $("<input>", { value: soapAction, type: "text"});
});
} else {
soapActionNode.find("soap-action")
.remove();
}
// 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("<span>SOAP Action</span>");
soapActionNode.replaceWith(function (i, e) {
return $("<input>", { 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 = $("<textarea>").text(soapBody);
root_node.find("soap-body")
.replaceWith(newSoapBodyNode);
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 = $("<textarea>").text(soapBody);
root_node.find("soap-body")
.replaceWith(newSoapBodyNode);
newSoapBodyNode.before("<span>SOAP Body</span>");
var button = $("<input>", { 'type': 'submit',
'value': 'Try it out !'} ).appendTo(root_node);
var button = $("<input>", { 'type': 'submit',
'value': 'Try it out !'} ).appendTo(root_node);
// SOAP Response section
var response_div = $("<div>", {'class': 'hidden'});
root_node.append(response_div);
// SOAP Response section
var response_div = $("<div>", {'class': 'hidden'});
root_node.append(response_div);
// SOAP Request
response_div.append($("<h2>SOAP Request Sent</h2>"));
var requestNode = $("<textarea>", { "readonly": true });
requestNode.appendTo(response_div);
// SOAP Request
response_div.append($("<h2>SOAP Request Sent</h2>"));
var requestNode = $("<textarea>", { "readonly": true });
requestNode.appendTo(response_div);
// SOAP Response
response_div.append($("<h2>SOAP Response Received</h2>"));
var responseNode = $("<textarea>", { "readonly": true });
responseNode.appendTo(response_div);
// SOAP Response
response_div.append($("<h2>SOAP Response Received</h2>"));
var responseNode = $("<textarea>", { "readonly": true });
responseNode.appendTo(response_div);
button.on('click', function (e) {
// stop the form to be submitted...
e.preventDefault();
button.on('click', function (e) {
// stop the form to be submitted...
e.preventDefault();
// empty the request and response panes
requestNode.empty();
responseNode.empty();
// empty the request and response panes
requestNode.empty();
responseNode.empty();
// Show the request and response pane
response_div.removeClass("hidden");
// Show the request and response pane
response_div.removeClass("hidden");
// Get the SOAP Body from the HTML form
soap_options.data = newSoapBodyNode.val();
// Get the SOAP Body from the HTML form
soap_options.data = newSoapBodyNode.val();
soap_options.beforeSend = function (soap) {
var request = soap.toString();
request = vkbeautify.xml(request, 2);
requestNode.text(request);
};
soap_options.success = function (soapResponse) {
soapResponse = soapResponse.toString();
soapResponse = vkbeautify.xml(soapResponse, 2);
responseNode.text(soapResponse);
};
soap_options.error = function (soapResponse) {
soapResponse = soapResponse.toString();
soapResponse = vkbeautify.xml(soapResponse, 2);
responseNode.text(soapResponse);
};
$.soap(soap_options);
});
soap_options.beforeSend = function (soap) {
var request = soap.toString();
request = vkbeautify.xml(request, 2);
requestNode.text(request);
};
soap_options.success = function (soapResponse) {
soapResponse = soapResponse.toString();
soapResponse = vkbeautify.xml(soapResponse, 2);
responseNode.text(soapResponse);
};
soap_options.error = function (soapResponse) {
soapResponse = soapResponse.toString();
soapResponse = vkbeautify.xml(soapResponse, 2);
responseNode.text(soapResponse);
};
$.soap(soap_options);
});
};
return $.soapui = soapui;

Loading…
Cancel
Save