JSFiddle - React, Tailwind, and code Playground
JavaScript
(function(angular){
'use strict';
var myModule = angular.module('myModule', []);
/**
* This provider adds SOAP support to the $http service
* @class soap-interceptorProvider
* @module myModule
* @namespace myModule
*/
myModule.provider('myModule.soap-interceptor', ['$httpProvider', function($httpProvider){
var providerInstance = this;
/**
* This is a cache for WSDL schemas where the key is the SOAP service base url and the value is the
* service's WSDL
* @class WsdlCache
* @module myModule
* @namespace myModule
*/
function WsdlCache(){
var wsdlCacheInstance = this;
/**
* This object holds the cached WSDLs and URLs.
* @prop rawCache
* @type {object}
*/
wsdlCacheInstance.rawCache = {};
/**
* Safely add a new WSDL to the service. This will later be used to compose SOAP request for the given URL.
* @method setWSDL
* @param {string} url - the base URL of the soap service
* @param {string} wsdl - the xml string of the wsdl of the SOAP service.
*/
wsdlCacheInstance.setWSDL = function(url, wsdl){
if(!wsdlCacheInstance.rawCache.hasOwnProperty(url)){
if(angular.isString(wsdl)){
wsdl = $.parseXML(wsdl);
}
wsdlCacheInstance.rawCache[url] = wsdl;
}
};
/**
* Check if a given url has a WSDL in cache.
* @param {string} url - full SOAP action url, including method and query
* @returns {boolean}
*/
wsdlCacheInstance.inCache = function(url){
var result = false,
currentUrl;
// look for the base url in the cache and make sure it has a...