public ServiceRequest UpdateSR(ServiceRequest sr, int _logIncidentId = 0, int _logContactId = 0)
        {
            if (String.IsNullOrWhiteSpace(SRServiceURL) || String.IsNullOrWhiteSpace(SRServiceUsername) || String.IsNullOrWhiteSpace(SRServicePassword))
            {
                throw new Exception("Provider's InitForSR not run.");
            }

            ServiceRequest result = sr;
            string request = "";
            string response = "";
            string logMessage, logNote;

            SR.CS_SERVICEREQUEST_PUB_Service client = EBSProxyFactory.GetSRServiceInstance(SRServiceURL, SRServiceUsername, SRServicePassword, SRServiceTimeout);

            SR.SOAHeader hdr = new SR.SOAHeader();
            hdr.Responsibility = "SERVICE";
            hdr.RespApplication = "CS";
            hdr.Org_Id = "204";
            hdr.SecurityGroup = "STANDARD";
            hdr.NLSLanguage = "AMERICAN";

            client.SOAHeaderValue = hdr;


            // Now to set the values for the request            

            if (sr.RequestID.HasValue)
            {
                SR_UPDATE_FIELDS sr_info = new SR_UPDATE_FIELDS();
                // SR.APPSCS_SERVICEREQUEST_PUB_SERVIC7 req_info = new SR.APPSCS_SERVICEREQUEST_PUB_SERVIC7();

                sr_info.REQUEST_DATE = sr.RequestDate;
                sr_info.REQUEST_DATESpecified = true;
                sr_info.TYPE_ID = sr.RequestTypeID;
                sr_info.TYPE_IDSpecified = true;
                sr_info.STATUS_ID = sr.StatusID;
                sr_info.STATUS_IDSpecified = true;
                sr_info.SEVERITY_ID = sr.SeverityID;
                sr_info.SEVERITY_IDSpecified = true;
                sr_info.SUMMARY = sr.Summary;
                sr_info.CURRENT_SERIAL_NUMBER = sr.SerialNumber;
                //req_info.CONTRACT_ID = 38373;
                sr_info.CONTRACT_IDSpecified = true;

                // added by rranaa for oow 2014
                sr_info.EXTERNAL_ATTRIBUTE_14 = sr.IncidentRef;
                sr_info.EXTERNAL_ATTRIBUTE_15 = sr.IncidentID;

                // Hard-coding some values
                if (String.IsNullOrEmpty(sr.ContactOrgID) || sr.ContactOrgID == "0")
                    sr_info.CUSTOMER_ID = 4429;
                else
                    sr_info.CUSTOMER_ID = Convert.ToDecimal(sr.ContactOrgID);
                sr_info.CUSTOMER_IDSpecified = true;
                sr_info.CALLER_TYPE = "ORGANIZATION";

                if (sr.OwnerID.HasValue)
                {
                    sr_info.OWNER_ID = sr.OwnerID;
                    sr_info.OWNER_IDSpecified = true;
                }
                /*

                if (sr.InstanceID.HasValue)
                {
                    sr_info.CUSTOMER_PRODUCT_ID = sr.InstanceID.Value;
                    sr_info.CUSTOMER_PRODUCT_IDSpecified = true;
                }
                */
                sr_info.VERIFY_CP_FLAG = "N";
                if (sr.ProductID.HasValue)
                {
                    sr_info.CUSTOMER_PRODUCT_ID = sr.ProductID;
                    sr_info.CUSTOMER_PRODUCT_IDSpecified = true;
                    sr_info.INVENTORY_ORG_ID = 204;
                    sr_info.INVENTORY_ORG_IDSpecified = true;

                }
                else
                {
                    sr_info.CUSTOMER_PRODUCT_ID = null;
                    sr_info.CUSTOMER_PRODUCT_IDSpecified = true;
                    sr_info.INVENTORY_ORG_ID = 204;
                    sr_info.INVENTORY_ORG_IDSpecified = true;
                }


                SR.InputParameters8 ip_update_sr = new SR.InputParameters8();
                ip_update_sr.P_REQUEST_ID = sr.RequestID;
                ip_update_sr.P_REQUEST_IDSpecified = true;
                ip_update_sr.P_REQUEST_NUMBER = sr.RequestNumber;
                ip_update_sr.P_API_VERSION = 4.0M;
                ip_update_sr.P_API_VERSIONSpecified = true;
                ip_update_sr.P_SERVICE_REQUEST_REC = sr_info;

                ip_update_sr.P_OBJECT_VERSION_NUMBER = sr.SrObjVerNum;
                ip_update_sr.P_OBJECT_VERSION_NUMBERSpecified = true;

                // Hard-coding the contact for the demo


                List<SR_UPDATE_CONTACT> clist = new List<SR_UPDATE_CONTACT>();

                ip_update_sr.P_CONTACTS = clist.ToArray();

                // Notes
                List<SR_UPDATE_NOTES> notes = new List<SR_UPDATE_NOTES>();
                if (!String.IsNullOrWhiteSpace(sr.Notes))
                {
                    SR_UPDATE_NOTES note = new SR_UPDATE_NOTES();
                    note.NOTE = sr.Notes;
                    note.NOTE_CONTEXT_TYPE_01 = String.Empty;
                    note.NOTE_CONTEXT_TYPE_02 = String.Empty;
                    note.NOTE_CONTEXT_TYPE_03 = String.Empty;
                    note.NOTE_DETAIL = String.Empty;
                    note.NOTE_TYPE = String.Empty;

                    notes.Add(note);

                }
                ip_update_sr.P_NOTES = notes.ToArray();

                ip_update_sr.P_AUTO_ASSIGN = String.Empty;
                ip_update_sr.P_DEFAULT_CONTRACT_SLA_IND = "Y";
                ip_update_sr.P_INIT_MSG_LIST = "T";
                ip_update_sr.P_COMMIT = "T";
                ip_update_sr.P_REQUEST_NUMBER = String.Empty;
                ip_update_sr.P_CALLED_BY_WORKFLOW = String.Empty;
                Stopwatch stopwatch = new Stopwatch();
                try
                {
                    request = serializer.Serialize(ip_update_sr);
                    stopwatch.Start();
                    SR.OutputParameters8 op_update_sr = client.UPDATE_SERVICEREQUEST(ip_update_sr);
                    stopwatch.Stop();
                    response = serializer.Serialize(op_update_sr);

                    if (op_update_sr.X_RETURN_STATUS == "S")
                    {
                        SR_UPDATE data = op_update_sr.X_SR_UPDATE_OUT_REC;

                        logMessage = "Request of updating Service Request (Success). SR ID = " + sr.RequestID;
                        logNote = "Request Payload: " + request;
                        log.DebugLog(_logIncidentId, _logContactId, logMessage, logNote);

                        logMessage = "Response of updating Service Request (Success). SR ID = " + sr.RequestID;
                        logNote = "Response Payload: " + response;
                        log.DebugLog(_logIncidentId, _logContactId, logMessage, logNote, (int)stopwatch.ElapsedMilliseconds);
                    }
                    else
                    {
                        result.ErrorMessage = "There has been an error communicating with EBS. Please check log for detail.";
                        
                        logMessage = "Request of updating Service Request (Failure). SR ID = " + sr.RequestID + " Error: " + op_update_sr.X_MSG_DATA;
                        logNote = "Request Payload: " + request;
                        log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);

                        logMessage = "Response of updating Service Request (Failure). SR ID = " + sr.RequestID + " Error: " + op_update_sr.X_MSG_DATA;
                        logNote = "Response Payload: " + response;
                        log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);
                    }

                }
                catch (Exception ex)
                {
                    result.ErrorMessage = "There has been an error communicating with EBS. Please check log for detail.";
                    
                    logMessage = "Request of updating Service Request (Failure). SR ID = " + sr.RequestID + " Error: " + ex.Message;
                    logNote = "Request Payload: " + request;
                    log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);

                    logMessage = "Response of updating Service Request (Failure). SR ID = " + sr.RequestID + " Error: " + ex.Message;
                    logNote = "Response Payload: " + response;
                    log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);

                    handleEBSException(ex, "Update Service Request", _logIncidentId, _logContactId);
                }
            }


            return result;

        }
 /// <remarks/>
 public void UPDATE_SERVICEREQUESTAsync(InputParameters8 InputParameters) {
     this.UPDATE_SERVICEREQUESTAsync(InputParameters, null);
 }
 /// <remarks/>
 public void UPDATE_SERVICEREQUESTAsync(InputParameters8 InputParameters, object userState) {
     if ((this.UPDATE_SERVICEREQUESTOperationCompleted == null)) {
         this.UPDATE_SERVICEREQUESTOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUPDATE_SERVICEREQUESTOperationCompleted);
     }
     this.InvokeAsync("UPDATE_SERVICEREQUEST", new object[] {
                 InputParameters}, this.UPDATE_SERVICEREQUESTOperationCompleted, userState);
 }
 /// <remarks/>
 public System.IAsyncResult BeginUPDATE_SERVICEREQUEST(InputParameters8 InputParameters, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("UPDATE_SERVICEREQUEST", new object[] {
                 InputParameters}, callback, asyncState);
 }