public object[] DoOperation(string operation, string model, string objectname, string qualifier) { log.Info("->"); this.model = model; this.operation = operation; this.objectname = objectname; this.qualifier = qualifier; this.fields = "*"; try { //if (setup()) //{ result = execRequest(); mc = result.result_data; object[] resultObjectArray = mc.Items; return(resultObjectArray); //} //else //{ // return null; //} } catch (Exception e) { log.Info("SMSService failed with an unexpected exception:"); log.Info(e.Message); log.Info(e.StackTrace); return(null); } finally { //releaseSession(); log.Info("<-"); } }
// Step 2: submitRequest() // Submits the SOAP request defined in the SMSTest object to the SMS web service for processing. private Result submitRequest() { // l submitRequestType requestType = null; returnType returnT = null; Result result = null; // We track whether a fault was raised, because it affects whether we copy session info from the response header later faultRaised = false; // Send the SOAP request to SMS running on the AES server String mType = WEB_REFERENCE_NAMESPACE + "." + model + "Type"; try { // Try to create model type Type modelType = Type.GetType(mType, true); // true fail on error - model doesnt exist! object[] modelArray = new object[1]; modelArray[0] = System.Activator.CreateInstance(modelType); // Populate Fields modelArray[0] = populateFields(modelArray[0]); requestType = new submitRequestType(); requestType.modelFields = new modelChoices(); requestType.modelFields.Items = modelArray; requestType.objectname = objectname; // objectname, not presently used requestType.operation = operation; requestType.qualifier = qualifier; returnT = sms.submitRequest(requestType); result = returnT.@return; } catch (TypeLoadException tle) { log.Info("ModelType: " + mType + " could not be loaded! Please verify this is a valid model."); log.Info(tle.Message); log.Info(tle.StackTrace); faultRaised = true; } catch (SoapException soapE) { // A fault was raised. The fault message will contain the explanation if (soapE.Message != null) { log.Info("Code: " + soapE.Code.Name); } if (soapE.Message != null) { log.Info("Message: " + soapE.Message); } if (soapE.Detail != null) { log.Info("Detail: " + soapE.Detail.InnerXml); } log.Info("A SOAP fault was raised: "); log.Info(soapE.Message); log.Info(soapE.StackTrace); faultRaised = true; } catch (Exception re) { // A fault was raised. The fault message will contain the explanation log.Info("An unexpected Exception was raised: "); log.Info(re.Message); log.Info(re.StackTrace); faultRaised = true; } // If we got a result (not a fault) then we'll show it if (!faultRaised) { // The result code indicates success or failure (CM rejected the request) if (result.result_code == 0) { log.Info("The request was successful (result_code == 0)"); modelChoices mc = result.result_data; // How many items were returned int resultLength = mc.Items.Length; if (resultLength > 0) { // We'll use a routine to illustrate processing the return values //prettyPrint(mc); } } else { faultRaised = true; // In case CM rejected the request, the message text will contain CM's explanation log.Info("The request returned an error (result_code == " + result.result_code + ")"); log.Info("result_data == " + '"' + result.result_data.Items + '"'); log.Info("message_text == " + result.message_text); } } return(result); }