Thursday, April 14, 2011

How to Read SOAP Response In siebel

function ReadResponse(psInput,psOutput)


{

//******************************************************

// Description: The purpose of this function is to read the



incoming response XML from middleware and check for success/error.



//**********************************************************

var psParent;

var psChild;

//var psInCopy = TheApplication().NewPropertySet();





try {

var isSuccess =

true;

psParent = TheApplication ().NewPropertySet ();

psParent = psInput;

var iChildCount = psParent.GetChildCount();



psChild =

TheApplication ().NewPropertySet ();

//var strLevelType = psParent.GetType();

//var strLevel ="";

var isTraversing = true;

var iChild = 0

var

strResponseType;

var strErrorCode = "";

var strErrorMessage = "";

var strErrorSeverity = "";

var blnIsErrorDetail = false;

while ((isTraversing)

&& (iChildCount > 0) && (iChild < iChildCount)) {

psChild = psParent.GetChild(iChild);

iChild++;

//strLevelType

= psChild.GetType();

// *** UNCOMMENT TO TRACE *********

// TheApplication().Trace("(" + iChild + "/" + + iChildCount + ") " + strLevelType);

//*******************************************************



// check for parent tags to force drill down to specific child tags

// if

(psChild.GetType() == "CustomerInfoAccessResponse") {

if ((psChild.GetType() == "CustomerInfoAccessResponse")

(psChild.GetType() == "PayLoad")



(psChild.GetType() == "Operation")

(psChild.GetType() == "Output")

((psChild.GetType() == "ErrorMessage") && (blnIsErrorDetail))) {

if

(psChild.GetType() == "Output") {

blnIsErrorDetail = true;

}

psParent = psChild;



iChildCount = psParent.GetChildCount();

iChild = 0;

// check for tags to get values

} else if

(psChild.GetType() == "ResponseType") {

strResponseType = psChild.GetValue();

if (strResponseType != "ACK") {



isSuccess = false;

}

} else if (psChild.GetType() == "ErrorMessage") {

// this tag is used 2

ways - as parent and child-value - ignore error

try {

strErrorMessage = strErrorMessage + psChild.GetValue();



} catch(e) {}

} else if (psChild.GetType() == "ErrorCode") {

strErrorCode = psChild.GetValue();

} else

if (psChild.GetType() == "ErrorDetailMessage") {

strErrorMessage = strErrorMessage + "; Detail: " + psChild.GetValue();

} else

if (psChild.GetType() == "ErrorSeverity") {

strErrorSeverity = psChild.GetValue();

}

}





psOutput.SetProperty("WMService","getOpportunityByReservation");

if (isSuccess) {

psOutput.SetProperty("Error Message",strErrorMessage);



psOutput.SetProperty("Response","Success");

psOutput.SetProperty("ErrorCode","None");

psOutput.SetProperty("ErrorApp","None");



psOutput.SetProperty("DisplayMsgCode","ACK");



// KCS -08/28/06-added code here to parse inputs and update the outputs

//

either removing the Status property or changing the value of the

// status property.

} else {

psOutput.SetProperty("Error

Message",strErrorMessage);

psOutput.SetProperty("Response","Error");

psOutput.SetProperty("ErrorCode",strErrorCode);



psOutput.SetProperty("ErrorApp",strErrorSeverity);

//psOutput.SetProperty("DisplayMsgCode",strResponseType);



psOutput.SetProperty("DisplayMsgCode","Dta01");

}



} catch(e) {

throw(e);

} finally {

psParent = null;

psChild = null;

}

}



No comments:

Post a Comment