

CREATE COMPUTE MODULE MAIN_WS_GENERIC_MODIFY_MSG
	CREATE FUNCTION Main() RETURNS BOOLEAN
	BEGIN
		CALL CopyMessageHeaders();
		CALL CopyEntireMessage();
		
		SET OutputLocalEnvironment = InputLocalEnvironment;
		
		CALL deleteXsiXsd();
		
		DELETE FIELD OutputRoot.SOAP.Body.ns15:RequestABCS.security.xmlns;
		DELETE FIELD OutputRoot.SOAP.Body.ns15:RequestMBASE.security.xmlns;
		
		DELETE FIELD OutputRoot.SOAP.Body.ns15:RequestABCS.requestabcs.xmlns;
		DELETE FIELD OutputRoot.SOAP.Body.ns15:RequestMBASE.requestmbase.xmlns;
		
		DELETE FIELD OutputRoot.SOAP.Body.ns15:RequestABCS.transactioncode.xmlns;
		DELETE FIELD OutputRoot.SOAP.Body.ns15:RequestMBASE.transactioncode.xmlns;

		DELETE FIELD OutputRoot.SOAP.Body.xsi;
		DELETE FIELD OutputRoot.SOAP.Body.xsd;
		DELETE FIELD OutputRoot.SOAP.Context."_XmlDeclaration";
		DELETE FIELD OutputRoot.HTTPInputHeader."User-Agent";
		DELETE FIELD OutputRoot.HTTPInputHeader.Vsdebuggercausalitydata;				

		DELETE FIELD OutputRoot.SOAP.Body.ns15:RequestRPGCall.xmlns;
		DELETE FIELD OutputRoot.SOAP.Body.ns15:RequestABCS.xmlns;
		DELETE FIELD OutputRoot.SOAP.Body.ns15:RequestMBASE.xmlns;
		
		DELETE FIELD OutputRoot.SOAP.Body.ns15:RequestRPGCall.security.xmlns;
		DELETE FIELD OutputRoot.SOAP.Body.ns15:RequestABCS.security.xmlns;
		DELETE FIELD OutputRoot.SOAP.Body.ns15:RequestMBASE.security.xmlns;
		
		DELETE FIELD OutputRoot.SOAP.Body.ns15:RequestRPGCall.requestrpg.xmlns;
		DELETE FIELD OutputRoot.SOAP.Body.ns15:RequestABCS.requestabcs.xmlns;
		DELETE FIELD OutputRoot.SOAP.Body.ns15:RequestMBASE.requestmbase.xmlns;
        DELETE FIELD OutputRoot.SOAP.Body.ns15:RequestABCS.*:ns2;
--		DELETE FIELD OutputRoot.SOAP.Body.*[1].security.xmlns;
--		DELETE FIELD OutputRoot.SOAP.Body.*[1].requestrpg.xmlns;
--		DELETE FIELD OutputRoot.SOAP.Body.*[1].xmlns;
--		SET OutputRoot.XMLNSC.data.body.security = InputRoot.SOAP.Body.*[1].security;

		RETURN TRUE;
	END;

	CREATE PROCEDURE deleteXsiXsd() BEGIN
		DECLARE I INTEGER 1;
		DECLARE J INTEGER;
		SET J = CARDINALITY(InputRoot.SOAP.Body.*[]);
		WHILE I <> J DO
			DELETE FIELD OutputRoot.SOAP.Body.*[1];
			--SET OutputRoot.XMLNSC.data.irsh = J;
			SET I = I + 1;
		END WHILE;
	END;
	
	CREATE PROCEDURE CopyMessageHeaders() BEGIN
		DECLARE I INTEGER 1;
		DECLARE J INTEGER;
		SET J = CARDINALITY(InputRoot.*[]);
		WHILE I < J DO
			SET OutputRoot.*[I] = InputRoot.*[I];
			SET I = I + 1;
		END WHILE;
	END;

	CREATE PROCEDURE CopyEntireMessage() BEGIN
		SET OutputRoot = InputRoot;
	END;
END MODULE;


CREATE FILTER MODULE MAIN_WS_GENERIC_Filter
	CREATE FUNCTION Main() RETURNS BOOLEAN
	BEGIN
		RETURN TRUE;
	END;

END MODULE;




CREATE COMPUTE MODULE MAIN_WS_GENERIC_SET_RESPONSE_NOT_AUTH
	CREATE FUNCTION Main() RETURNS BOOLEAN
	BEGIN
		--CALL CopyMessageHeaders();
		--CALL CopyEntireMessage();
		
		SET OutputRoot.XMLNSC.wsns:Fault.faultcode = '999';
		SET OutputRoot.XMLNSC.wsns:Fault.faultstring = 'Application not authorized';
		
		
		RETURN TRUE;
	END;

	CREATE PROCEDURE CopyMessageHeaders() BEGIN
		DECLARE I INTEGER 1;
		DECLARE J INTEGER;
		SET J = CARDINALITY(InputRoot.*[]);
		WHILE I < J DO
			SET OutputRoot.*[I] = InputRoot.*[I];
			SET I = I + 1;
		END WHILE;
	END;

	CREATE PROCEDURE CopyEntireMessage() BEGIN
		SET OutputRoot = InputRoot;
	END;
END MODULE;


CREATE COMPUTE MODULE MAIN_WS_GENERIC_DELETE_RESPONSE_VALIDATION
	CREATE FUNCTION Main() RETURNS BOOLEAN
	BEGIN
		--kata remond CALL CopyMessageHeaders();
		CALL CopyEntireMessage();
		
		--kata remond SET OutputLocalEnvironment = InputLocalEnvironment;
		DELETE FIELD OutputRoot.XMLNSC;
		RETURN TRUE;
	END;

	CREATE PROCEDURE CopyMessageHeaders() BEGIN
		DECLARE I INTEGER 1;
		DECLARE J INTEGER;
		SET J = CARDINALITY(InputRoot.*[]);
		WHILE I < J DO
			SET OutputRoot.*[I] = InputRoot.*[I];
			SET I = I + 1;
		END WHILE;
	END;

	CREATE PROCEDURE CopyEntireMessage() BEGIN
		SET OutputRoot = InputRoot;
	END;
END MODULE;


CREATE COMPUTE MODULE MAIN_WS_GENERIC_SET_GENERAL_ERROR
	CREATE FUNCTION Main() RETURNS BOOLEAN
	BEGIN
		-- CALL CopyMessageHeaders();
		-- CALL CopyEntireMessage();
		
		IF InputRoot.XMLNSC.data.error IS NOT NULL THEN
			SET OutputRoot.XMLNSC.wsns:Fault.faultcode = '000';
			SET OutputRoot.XMLNSC.wsns:Fault.faultstring = InputRoot.XMLNSC.data.error;
		ELSE		
			SET OutputRoot.XMLNSC.wsns:Fault.faultcode = '990';
			SET OutputRoot.XMLNSC.wsns:Fault.faultstring = 'General Error';
		END IF;
		
		RETURN TRUE;
	END;

	CREATE PROCEDURE CopyMessageHeaders() BEGIN
		DECLARE I INTEGER 1;
		DECLARE J INTEGER;
		SET J = CARDINALITY(InputRoot.*[]);
		WHILE I < J DO
			SET OutputRoot.*[I] = InputRoot.*[I];
			SET I = I + 1;
		END WHILE;
	END;

	CREATE PROCEDURE CopyEntireMessage() BEGIN
		SET OutputRoot = InputRoot;
	END;
END MODULE;


CREATE COMPUTE MODULE MAIN_WS_GENERIC_SET_RESPONSE_INVALID_APP
	CREATE FUNCTION Main() RETURNS BOOLEAN
	BEGIN
		-- CALL CopyMessageHeaders();
		-- CALL CopyEntireMessage();
		
		SET OutputRoot.XMLNSC.wsns:Fault.faultcode = '0000';
		SET OutputRoot.XMLNSC.wsns:Fault.faultstring = 'Invalid Hashcode';
		
		RETURN TRUE;
	END;

	CREATE PROCEDURE CopyMessageHeaders() BEGIN
		DECLARE I INTEGER 1;
		DECLARE J INTEGER;
		SET J = CARDINALITY(InputRoot.*[]);
		WHILE I < J DO
			SET OutputRoot.*[I] = InputRoot.*[I];
			SET I = I + 1;
		END WHILE;
	END;

	CREATE PROCEDURE CopyEntireMessage() BEGIN
		SET OutputRoot = InputRoot;
	END;
END MODULE;


CREATE COMPUTE MODULE MAIN_WS_GENERIC_SET_SECURE_PASSWORD
	CREATE FUNCTION Main() RETURNS BOOLEAN
	BEGIN
		CALL CopyMessageHeaders();
		CALL CopyEntireMessage();
		
		if InputRoot.SOAP.Body.ns15:RequestRPGCall.requestrpg.password is not NULL then
		SET OutputRoot.HTTPInputHeader."Accept-Encoding" = 'gzip,deflate';
		SET OutputRoot.SOAP.Body.ns15:RequestRPGCall.requestrpg.password.secure__ = 'true';
		end if;
		RETURN TRUE;
	END;

	CREATE PROCEDURE CopyMessageHeaders() BEGIN
		DECLARE I INTEGER 1;
		DECLARE J INTEGER;
		SET J = CARDINALITY(InputRoot.*[]);
		WHILE I < J DO
			SET OutputRoot.*[I] = InputRoot.*[I];
			SET I = I + 1;
		END WHILE;
	END;

	CREATE PROCEDURE CopyEntireMessage() BEGIN
		SET OutputRoot = InputRoot;
	END;
END MODULE;


CREATE COMPUTE MODULE MAIN_WS_GENERIC_SET_localEnv
	CREATE FUNCTION Main() RETURNS BOOLEAN
	BEGIN
		--CALL CopyMessageHeaders();
		CALL CopyEntireMessage();
		DECLARE soapenv NAMESPACE 'http://schemas.xmlsoap.org/soap/envelope/';
		--SET OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.soapenv:localEnv.request_timestamp = InputLocalEnvironment.request_timestamp;
		--SET OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.soapenv:localEnv.request_id = InputLocalEnvironment.request_id;
		
		SET OutputRoot.HTTPInputHeader."X-Original-HTTP-Command" = InputRoot.XMLNSC.data.request."X-Original-HTTP-Command";

--		SET OutputRoot = InputRoot;
		--SET OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.soapenv:localEnv = InputLocalEnvironment;
		SET OutputLocalEnvironment = InputLocalEnvironment;
		
		SET OutputLocalEnvironment.WrittenDestination.MQ.DestinationData.queueName = 'LOG_DB_SOAP_REPLY';

		RETURN TRUE;
	END;

	CREATE PROCEDURE CopyEntireMessage() BEGIN
		SET OutputRoot = InputRoot;
	END;
	
	CREATE PROCEDURE CopyMessageHeaders() BEGIN
		DECLARE I INTEGER 1;
		DECLARE J INTEGER;
		SET J = CARDINALITY(InputRoot.*[]);
		WHILE I < J DO
			SET OutputRoot.*[I] = InputRoot.*[I];
			SET I = I + 1;
		END WHILE;
	END;
	
END MODULE;


CREATE COMPUTE MODULE MAIN_WS_GENERIC_SET_LENV_REPLY
	CREATE FUNCTION Main() RETURNS BOOLEAN
	BEGIN
		SET OutputRoot = InputRoot;

		DECLARE soapenv NAMESPACE 'http://schemas.xmlsoap.org/soap/envelope/';
		SET OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.soapenv:localEnv = InputLocalEnvironment;

		RETURN TRUE;
	END;
END MODULE;








