SOAP Call returning an error after upgrading to Kingston

Sue Frost
Giga Guru

We are in the process of upgrading to Kingston Patch 8.

A custom, scoped application makes SOAP calls through DataPower and MQ to our home-grown mainframe system to retrieve data. These calls are failing - returning socket timeout errors and the log errors noted below.

We haven't updated these calls in months and they are working fine in our production environment. I do see a log error but I'm not technical enough to interpret it properly and I haven't had any luck with google.

Here's the Error log entry:

com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character 'S' (code 83) in prolog; expected '<'
 at [row,col {unknown-source}]: [1,1]: org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character 'S' (code 83) in prolog; expected '<'
 at [row,col {unknown-source}]: [1,1]: org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:297)
org.apache.axiom.om.impl.dom.DocumentImpl.getOMDocumentElement(DocumentImpl.java:446)
org.apache.axiom.om.impl.dom.DocumentImpl.getDocumentElement(DocumentImpl.java:458)
com.glide.util.XMLStreamDocument.getDocumentElement(XMLStreamDocument.java:397)
com.glide.util.XMLStreamDocument.isValid(XMLStreamDocument.java:225)
com.glide.util.XMLStreamDocument.selectSingleNode(XMLStreamDocument.java:364)
com.glide.util.XMLStreamDocument.selectSingleNode(XMLStreamDocument.java:356)
com.glide.util.XMLStreamDocument.selectSingleNodeText(XMLStreamDocument.java:350)
com.glide.script.XMLDocument2.jsFunction_getNodeText(XMLDocument2.java:60)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.mozilla.javascript.MemberBox.invoke(MemberBox.java:138)
org.mozilla.javascript.FunctionObject.doInvoke(FunctionObject.java:668)
org.mozilla.javascript.FunctionObject.call(FunctionObject.java:614)
org.mozilla.javascript.ScriptRuntime.doCall(ScriptRuntime.java:2582)
org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32)
org.mozilla.javascript.gen.sys_ui_action_5cbd08a6db5372006b4f534e5e96192b_script_2240._c_addressValidation_1(sys_ui_action.5cbd08a6db5372006b4f534e5e96192b.script:118)
org.mozilla.javascript.gen.sys_ui_action_5cbd08a6db5372006b4f534e5e96192b_script_2240.call(sys_ui_action.5cbd08a6db5372006b4f534e5e96192b.script)
org.mozilla.javascript.ScriptRuntime.doCall2(ScriptRuntime.java:2650)
org.mozilla.javascript.ScriptRuntime.doCall(ScriptRuntime.java:2590)
org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:74)
org.mozilla.javascript.gen.sys_ui_action_5cbd08a6db5372006b4f534e5e96192b_script_2240._c_script_0(sys_ui_action.5cbd08a6db5372006b4f534e5e96192b.script:11)
org.mozilla.javascript.gen.sys_ui_action_5cbd08a6db5372006b4f534e5e96192b_script_2240.call(sys_ui_action.5cbd08a6db5372006b4f534e5e96192b.script)
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:563)
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3428)
org.mozilla.javascript.gen.sys_ui_action_5cbd08a6db5372006b4f534e5e96192b_script_2240.call(sys_ui_action.5cbd08a6db5372006b4f534e5e96192b.script)
org.mozilla.javascript.gen.sys_ui_action_5cbd08a6db5372006b4f534e5e96192b_script_2240.exec(sys_ui_action.5cbd08a6db5372006b4f534e5e96192b.script)
com.glide.script.ScriptEvaluator.execute(ScriptEvaluator.java:279)
com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:118)
com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:82)
com.glide.script.GlideRhinoHelper.evaluateAsString(GlideRhinoHelper.java:135)
com.glide.script.ActionScript.conditionalEval(ActionScript.java:97)
com.glide.script.ActionScript.execute(ActionScript.java:82)
com.glide.script.ActionScriptProcessor.processScript(ActionScriptProcessor.java:144)
com.glide.script.Action.process(Action.java:116)
com.glide.ui.RedirectTransaction.invokeAction(RedirectTransaction.java:524)
com.glide.ui.RedirectTransaction.handleActions(RedirectTransaction.java:480)
com.glide.ui.RedirectTransaction.inboundActions(RedirectTransaction.java:316)
com.glide.ui.RedirectTransaction.process(RedirectTransaction.java:182)
com.glide.ui.GlideServletUITransaction.process(GlideServletUITransaction.java:93)
com.glide.processors.AProcessor.runProcessor(AProcessor.java:483)
com.glide.processors.AProcessor.processTransaction(AProcessor.java:205)
com.glide.processors.ProcessorRegistry.process0(ProcessorRegistry.java:178)
com.glide.processors.ProcessorRegistry.process(ProcessorRegistry.java:167)
com.glide.ui.GlideServletTransaction.process(GlideServletTransaction.java:31)
com.glide.sys.Transaction.run(Transaction.java:2038)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:748)

 

The Request Body is as follows:

Request Body: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:add="http://AddressServiceSoapWrapper">
   <soapenv:Header/>	
   <soapenv:Body>
      <add:ValidateAddress>
         <requestCode>VALPCADDR</requestCode>
         <languageCode>ENGLISH</languageCode>
         <addressLine1>67 MAPLEWOOD PL </addressLine1>
         <addressLine2> </addressLine2>
         <cityName>KITCHENER</cityName>
         <provinceCode>ON</provinceCode>
         <postalCode>N2H4L4</postalCode>
         <countryCode>CA</countryCode>
      </add:ValidateAddress>
   </soapenv:Body>
</soapenv:Envelope>

 

And here's the entire UI Action:

/*
Created by: Sue Frost
Created:    May 2017
Purpose: Reads the address queries ECOM to validate postal code

*/

//First - save the record
current.update();

addressValidation();

//Server-side function
function addressValidation(){
	
	var exUtil = new ExtremeQuoteAjaxScriptsPart2();
	var tableName = current.getTableName();
	var requestBody;
	var responseBody;
	var status;
	var city;
	var province;
	var postalCode, postalCodeNew;
	var pCode;
	var pLang;
	var msg;
	var sm;
	var soapFunction;
	
	try{

		//get soap call based on the instance you're running in
		var instanceName = gs.getProperty('instance_name');
		
		switch (instanceName.toString()) {
			case 'ecodevchild1': soapFunction = gs.getProperty('x_enig_quote_extrm.soap.function.dev'); break;
			case 'ecodevchild2': soapFunction = gs.getProperty('x_enig_quote_extrm.soap.function.dev'); break;
			case 'ecodevchild3': soapFunction = gs.getProperty('x_enig_quote_extrm.soap.function.dev'); break;
			case 'ecodevparent': soapFunction = gs.getProperty('x_enig_quote_extrm.soap.function.qa'); break;
			case 'ecostaging': soapFunction = gs.getProperty('x_enig_quote_extrm.soap.function.staging'); break;
			case 'ecotraining': soapFunction = gs.getProperty('x_enig_quote_extrm.soap.function.staging'); break;
			case 'ecosandbox': soapFunction = gs.getProperty('x_enig_quote_extrm.soap.function.prod'); break;
			case 'economical': soapFunction = gs.getProperty('x_enig_quote_extrm.soap.function.prod'); break;
			default: soapFunction = soapFunction = gs.getProperty('x_enig_quote_extrm.soap.function.dev'); break;
		}
		
		sm = new sn_ws.SOAPMessageV2('x_enig_quote_extrm.Address Validation', soapFunction);
		
// 		//Build security login section
// 		var securityHeader = exUtil.buildSecurityHeader();	
// 		gs.addInfoMessage(securityHeader);
		
		//override authentication profile
		//authentication type ='basic'
		//r.setAuthentication(authentication type,profile name);
		
		//translate the language so that the fixed variable is sent
		var printLanguage = current.print_language;
		if(printLanguage == 'en'){
			pLang = 'ENGLISH';
		} else {
			pLang = 'FRENCH';
		}
		
		//gs.info("SUF - Point 1", 'Extreme Quote');
		
		//determine address formatting
		var contractAddressFormat = getAddressFormat(current.sys_id, tableName);   //"x_enig_quote_extrm_quote");
		//build address
		var addressText = buildAddress(current.sys_id, tableName, contractAddressFormat, printLanguage);
		
		//gs.info("SUF - Point 2 - tableName:  " + tableName, 'Extreme Quote');
		
		//set variables based on table
		if(tableName == 'x_enig_quote_extrm_quote'){
			city = current.city;
			province = current.province.u_abbreviation.toUpperCase();
			postalCode = current.postal_code;
		} else {
			city = current.location_city;
			province = current.location_province.u_abbreviation.toUpperCase();
			postalCode = current.location_postal_code;
		}
		
		//gs.info("SUF - postalCode - " + postalCode, 'Extreme Quote');
		
		//format postal code
		if( !postalCode.nil() ){
			pCode = postalCode.replace(/\s+/g, '');   //remove any spaces in the postal code
		} else {
			pCode = '';
		}
			
		//write them all out
		sm.setStringParameterNoEscape('requestCode', 'VALPCADDR');    //hard-coded value for call
		sm.setStringParameterNoEscape('languageCode', pLang);
		sm.setStringParameterNoEscape('addressLine1', addressText[0]);
		sm.setStringParameterNoEscape('addressLine2', addressText[1]);
		sm.setStringParameterNoEscape('cityName', city);
		sm.setStringParameterNoEscape('provinceCode', province);
		sm.setStringParameterNoEscape('postalCode', pCode);
		sm.setStringParameterNoEscape('countryCode', 'CA');     //hard-coded value
		
		sm.setHttpTimeout(50000); //In Milli seconds. Wait at most 10 seconds for response from http request.
		
		response = sm.execute();//Might throw exception if http connection timed out or some issue with sending request itself because 	of encryption/decryption of password and stuff
		responseBody = response.haveError() ? response.getErrorMessage() : response.getBody();
		status = response.getStatusCode();
		
		
		//PARSE RESPONSE & WRITE TO FIELDS
		var xmlDoc = new XMLDocument2();
		xmlDoc.parseXML(responseBody);
		
		var pc1 = xmlDoc.getNodeText("//postalCodePt1");
		var pc2 = xmlDoc.getNodeText("//postalCodePt2");
		var returnCode = xmlDoc.getNodeText("//returnCode");
		var reasonCode = xmlDoc.getNodeText("//reasonCode");   //Not sure we need this
				
		if(returnCode == "NOERRORS"){

			current.address_validation = '1';
			msg = gs.getMessage("address.validation.successful");
			postalCodeNew = pc1 + ' ' + pc2;

		} else if(returnCode == 'DATAERR'){

			current.address_validation = '3';
			msg = gs.getMessage("address.validation.dataerror");
			postalCodeNew = postalCode;

		} else if(returnCode == 'SYSERR'){

			current.address_validation = '3';
			msg = gs.getMessage("address.validation.dataerror");
			postalCodeNew = postalCode;

		} else {     //Other errors

			if(status == 500 || responseBody == "Socket timeout"){
				msg = gs.getMessage("address.validation.unsuccessful") + " - Timeout Error / Erreur d'expiration";
			} else {
				msg = gs.getMessage("address.validation.unsuccessful") + " - " + e;
			}
			
			current.address_validation = '2';
			postalCodeNew = postalCode;
		}
		
		//write out confirmed postal code
		if(tableName == 'x_enig_quote_extrm_quote'){
			current.postal_code = postalCodeNew;
		} else {
			current.location_postal_code = postalCodeNew;
		}
		
		gs.addInfoMessage(msg);
		
		
		//done
		current.update();
		action.setRedirectURL(current);
		//gs.addInfoMessage("SUF Address COMPLETE");
	}
	catch(e)
	{
		gs.info("Address Validation error: " + e, 'Extreme Quote');
		status = '500';
	}
	finally
	{
		requestBody = sm ? sm.getRequestBody():null;
	}
	
	gs.info("Request Body: " + requestBody, 'Extreme Quote');
	gs.info("Response: " + responseBody, 'Extreme Quote');
	gs.info("HTTP Status: " + status, 'Extreme Quote');
	
	action.setRedirectURL(current);
}


//Calls script include to determine the format of the Address lines
function getAddressFormat(sysID, tableName){
	
	var exScript = new ExtremeQuoteAjaxScripts();
	var functionresult = exScript.getAddressFormat(sysID, tableName);
	
	return functionresult;
}

//Calls script include to build address
function buildAddress(sysID, tableName, addressFormat, printLanguage){
	
	var exScript = new ExtremeQuoteAjaxScripts();
	var addressArray = exScript.buildAddress(sysID, tableName, addressFormat, printLanguage);
	
	return addressArray;
}

 

Can anyone see issues with all this? What I have been able to track down on google suggests an issue with the envelope, but that doesn't seem to be the case here.

Thank you!

2 REPLIES 2

marcguegueniat
Kilo Sage

Hi,

I can't explain the error, but you can see there is an error :

sys_ui_action.5cbd08a6db5372006b4f534e5e96192b.script:118

You should look at this 118 line

var reasonCode = xmlDoc.getNodeText("//reasonCode");   //Not sure we need this

Maybe try removing it? I don't see this variable used anywhere after in the code.

Regards,

Thank you!

The reasonCode is sometimes returned by the SOAP call, so it does need to be there.


As it turns out, the call failure is due to a DataPower upgrade that in progress and that I didn't find out about until too late.

Once we got the upgrade into Production, all the calls were fine. So nothing Kingston related.