public ServiceRequest LookupSR(string incident_id, int _logIncidentId = 0, int _logContactId = 0)
        {
            if (String.IsNullOrWhiteSpace(SRURL) || String.IsNullOrWhiteSpace(SRServiceUsername) || String.IsNullOrWhiteSpace(SRServicePassword))
            {
                throw new Exception("Provider's InitForSR not run.");
            }
            string request, response, logMessage, logNote;

            SRSVC.WC_Service_Request_BSClient client = new SRSVC.WC_Service_Request_BSClient(binding, addr);
            MyEndpointBehavior eBehavior = new MyEndpointBehavior();
            client.Endpoint.Behaviors.Add(eBehavior);
            if(SRServiceTimeout > 0)
                client.InnerChannel.OperationTimeout = TimeSpan.FromMilliseconds(SRServiceTimeout );

            SRSVC.WC_Service_Request_BSQueryPage_Input ip = new SRSVC.WC_Service_Request_BSQueryPage_Input();

            ServiceRequest sr = new ServiceRequest();

            ip.ListOfWc_Service_Request_Io = new SRSVC.ListOfWc_Service_Request_IoQuery();
            ip.ListOfWc_Service_Request_Io.ServiceRequest = new SRSVC.ServiceRequestQuery();
            ip.ListOfWc_Service_Request_Io.ServiceRequest.Id = new SRSVC.queryType();
            if (!String.IsNullOrEmpty(incident_id))
            {
                ip.ListOfWc_Service_Request_Io.ServiceRequest.Id.Value = "='" + incident_id + "'";
            }
            else
            {
                throw new Exception("Service Request ID is empty.");
            }

            ip.ListOfWc_Service_Request_Io.ServiceRequest.Description = new SRSVC.queryType();
            ip.ListOfWc_Service_Request_Io.ServiceRequest.Description.Value = String.Empty;

            ip.ListOfWc_Service_Request_Io.ServiceRequest.ContactId = new SRSVC.queryType();
            ip.ListOfWc_Service_Request_Io.ServiceRequest.ContactId.Value = String.Empty;

            ip.ListOfWc_Service_Request_Io.ServiceRequest.OwnedById = new SRSVC.queryType();
            ip.ListOfWc_Service_Request_Io.ServiceRequest.OwnedById.Value = String.Empty;

            ip.ListOfWc_Service_Request_Io.ServiceRequest.Owner = new SRSVC.queryType();
            ip.ListOfWc_Service_Request_Io.ServiceRequest.Owner.Value = String.Empty;

            ip.ListOfWc_Service_Request_Io.ServiceRequest.Priority = new SRSVC.queryType();
            ip.ListOfWc_Service_Request_Io.ServiceRequest.Priority.Value = String.Empty;

            ip.ListOfWc_Service_Request_Io.ServiceRequest.SRNumber = new SRSVC.queryType();
            ip.ListOfWc_Service_Request_Io.ServiceRequest.SRNumber.Value = String.Empty;

            ip.ListOfWc_Service_Request_Io.ServiceRequest.SRType = new SRSVC.queryType();
            ip.ListOfWc_Service_Request_Io.ServiceRequest.SRType.Value = String.Empty;

            ip.ListOfWc_Service_Request_Io.ServiceRequest.SerialNumber = new SRSVC.queryType();
            ip.ListOfWc_Service_Request_Io.ServiceRequest.SerialNumber.Value = String.Empty;

            ip.ListOfWc_Service_Request_Io.ServiceRequest.Severity = new SRSVC.queryType();
            ip.ListOfWc_Service_Request_Io.ServiceRequest.Severity.Value = String.Empty;

            ip.ListOfWc_Service_Request_Io.ServiceRequest.Status = new SRSVC.queryType();
            ip.ListOfWc_Service_Request_Io.ServiceRequest.Status.Value = String.Empty;

            ip.ListOfWc_Service_Request_Io.ServiceRequest.Type = new SRSVC.queryType();
            ip.ListOfWc_Service_Request_Io.ServiceRequest.Type.Value = String.Empty;

            ip.ListOfWc_Service_Request_Io.ServiceRequest.ProductId = new SRSVC.queryType();
            ip.ListOfWc_Service_Request_Io.ServiceRequest.ProductId.Value = String.Empty;

            ip.ListOfWc_Service_Request_Io.ServiceRequest.Product = new SRSVC.queryType();
            ip.ListOfWc_Service_Request_Io.ServiceRequest.Product.Value = String.Empty;


            ip.LOVLanguageMode = "LIC";
            ip.ViewMode = "All";
            Stopwatch stopwatch = new Stopwatch();
            try
            {
                SRSVC.WC_Service_Request_BSQueryPage_Output op;
                using (new OperationContextScope(client.InnerChannel))
                {
                    MessageHeader usrMsgHdr = MessageHeader.CreateHeader("UsernameToken", "http://siebel.com/webservices", SRServiceUsername);
                    OperationContext.Current.OutgoingMessageHeaders.Add(usrMsgHdr);
                    MessageHeader pwdMsgHdr = MessageHeader.CreateHeader("PasswordText", "http://siebel.com/webservices", SRServicePassword);
                    OperationContext.Current.OutgoingMessageHeaders.Add(pwdMsgHdr);
                    stopwatch.Start();
                    op = client.WC_Service_Request_BSQueryPage(ip);
                    stopwatch.Stop();
                    request = eBehavior.msgInspector.reqPayload;
                    response = eBehavior.msgInspector.resPayload;

                    SRSVC.ServiceRequestData opData = op.ListOfWc_Service_Request_Io.ServiceRequest[0];
                    sr.RequestID = opData.Id;
                    sr.RequestNumber = opData.SRNumber;
                    //sr.IncidentID
                    //sr.IncidentRef
                    sr.Status = opData.Status;
                    sr.Severity = opData.Severity;
                    sr.RequestType = opData.SRType;
                    sr.Summary = opData.Description;
                    sr.SerialNumber = opData.SerialNumber;
                    sr.Owner = opData.Owner;
                    sr.OwnerID = opData.OwnedById;
                    sr.Product = opData.ProductId;
                    sr.ProductDescription = opData.Product;
                }

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

                logMessage = "Response of loading Service Request (Success). SR ID = " + incident_id;
                logNote = "Response Payload: " + response;
                log.DebugLog(_logIncidentId, _logContactId, logMessage, logNote, (int)stopwatch.ElapsedMilliseconds);
            }
            catch (Exception ex)
            {
                request = eBehavior.msgInspector.reqPayload;
                response = eBehavior.msgInspector.resPayload;

                sr.ErrorMessage = "There has been an error communicating with Siebel. Please check log for detail.";
                logMessage = "Request of loading Service Request (Failure). SR ID = " + incident_id + " Error: " + ex.Message;
                logNote = "Request Payload: " + request;
                log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);

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

                handleSiebelException(ex, "Lookup Service Request", _logIncidentId, _logContactId);
            }
            return sr;
        }
        /*  call WC_Service_Request_BSClient : WC_Service_Request_BSQueryPage
         *  Output : WC_Service_Request_BSQueryPage_Output.ListOfWc_Service_Request_Io.ServiceRequest
         *  call dictAddProperty() to add the individual property name, type, and value
         *  for dynamic columns feature
         */
        public Dictionary<string, string> LookupSRDetail(IList<string> columns, string srId, int _logIncidentId = 0, int _logContactId = 0)
        {
            // can reuse Contact URL, service username and password, is all the same 
            if (String.IsNullOrWhiteSpace(SRURL) || String.IsNullOrWhiteSpace(SRServiceUsername) || String.IsNullOrWhiteSpace(SRServicePassword))
            {
                throw new Exception("Provider's InitForContact not run.");
            }
            string request, response, logMessage, logNote;
            SRSVC.WC_Service_Request_BSClient client = new SRSVC.WC_Service_Request_BSClient(binding, addr);
            MyEndpointBehavior eBehavior = new MyEndpointBehavior();
            client.Endpoint.Behaviors.Add(eBehavior);
            if(SRServiceTimeout > 0)
                client.InnerChannel.OperationTimeout = TimeSpan.FromMilliseconds(SRServiceTimeout );
            SRSVC.WC_Service_Request_BSQueryPage_Input ip = new SRSVC.WC_Service_Request_BSQueryPage_Input();
            ip.ListOfWc_Service_Request_Io = new SRSVC.ListOfWc_Service_Request_IoQuery();
            ip.ListOfWc_Service_Request_Io.ServiceRequest = new SRSVC.ServiceRequestQuery();

            foreach (PropertyInfo propertyInfo in ip.ListOfWc_Service_Request_Io.ServiceRequest.GetType().GetProperties())
            {
                foreach (string column in columns)
                {
                    if (propertyInfo.Name == column.Split('.')[1])
                    {
                        if (propertyInfo.PropertyType == typeof(SRSVC.queryType))
                        {
                            SRSVC.queryType queryType = new SRSVC.queryType();
                            propertyInfo.SetValue(ip.ListOfWc_Service_Request_Io.ServiceRequest, queryType, null);
                        }
                        break;
                    }
                }
            }

            ip.ListOfWc_Service_Request_Io.ServiceRequest.Id.Value = "='" + srId + "'";

            ip.LOVLanguageMode = "LIC";
            ip.ViewMode = "All";

            Stopwatch stopwatch = new Stopwatch();
            SRSVC.WC_Service_Request_BSQueryPage_Output opList;
            try
            {
                using (new OperationContextScope(client.InnerChannel))
                {
                    MessageHeader usrMsgHdr = MessageHeader.CreateHeader("UsernameToken", "http://siebel.com/webservices", SRServiceUsername);
                    OperationContext.Current.OutgoingMessageHeaders.Add(usrMsgHdr);
                    MessageHeader pwdMsgHdr = MessageHeader.CreateHeader("PasswordText", "http://siebel.com/webservices", SRServicePassword);
                    OperationContext.Current.OutgoingMessageHeaders.Add(pwdMsgHdr);
                    stopwatch.Start();
                    opList = client.WC_Service_Request_BSQueryPage(ip);
                    stopwatch.Stop();
                    request = eBehavior.msgInspector.reqPayload;
                    logMessage = "Request of SR detail (Success). Siebel srId = " + srId;
                    logNote = "Request Payload: " + request;
                    log.DebugLog(_logIncidentId, _logContactId, logMessage, logNote);
                    response = eBehavior.msgInspector.resPayload;
                    logMessage = "Response of SR detail (Success). Siebel srId = " + srId;
                    logNote = "Response Payload: " + response;
                    log.DebugLog(_logIncidentId, _logContactId, logMessage, logNote, (int)stopwatch.ElapsedMilliseconds);
                }
            }
            catch (Exception ex)
            {
                opList = client.WC_Service_Request_BSQueryPage(ip);
                request = eBehavior.msgInspector.reqPayload;
                logMessage = "Request of SR detail (Failure). Siebel srId = " + srId;
                logNote = "Request Payload: " + request;
                log.DebugLog(_logIncidentId, _logContactId, logMessage, logNote);
                response = eBehavior.msgInspector.resPayload;
                logMessage = "Response of SR detail (Failure). Siebel srId = " + srId;
                logNote = "Response Payload: " + response;
                log.DebugLog(_logIncidentId, _logContactId, logMessage, logNote);
                handleSiebelException(ex, "client.WC_Contacts_BSQueryPage(ip)");
                throw ex;
            }
            Dictionary<string, string> dictDetail = new Dictionary<string, string>();

            SRSVC.ServiceRequestData srData = opList.ListOfWc_Service_Request_Io.ServiceRequest[0];
            foreach (PropertyInfo propertyInfo in srData.GetType().GetProperties())
            {
                Object propVal = srData.GetType().GetProperty(propertyInfo.Name).GetValue(srData, null);
                dictAddProperty(propertyInfo, propVal, ref dictDetail);
            }

            return dictDetail;
        }