public static async Task <string> Get_TIMSS_SessionID() { try { var basicHttpBinding = new BasicHttpsBinding(BasicHttpsSecurityMode.Transport); basicHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; var endpointAddress = new EndpointAddress(new Uri(Utility.PersonifySSOWebService_Default)); PersonifySSOWebService.SimpleWebServiceSoapClient client = new PersonifySSOWebService.SimpleWebServiceSoapClient(basicHttpBinding, endpointAddress); if (client.State == System.ServiceModel.CommunicationState.Faulted) { client.Abort(); client = new PersonifySSOWebService.SimpleWebServiceSoapClient(basicHttpBinding, endpointAddress); } string login = Utility.PIWSAcc_Login; string passwd = Utility.PIWSAcc_Password; string orgid = Utility.Pws_Acc_OrgId; string unitid = Utility.Pws_Acc_OrgUnitId; var ret = await client.ConnectAsync(login, passwd, orgid, unitid).ConfigureAwait(false); client.Abort(); return(ret.Token); } catch (Exception e) { string msg = e.Message; throw; } }
public static async Task <DataSet> AMS_Query_Result(string spName, string paramList, string paramValueList) //, string PersonifySSOWebService) { PersonifySSOWebService.SimpleWebServiceSoapClient client = null; DataSet myDataSet = new DataSet(); try { var basicHttpBinding = new BasicHttpsBinding(BasicHttpsSecurityMode.Transport); basicHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; var endpointAddress = new EndpointAddress(new Uri(Utility.PersonifySSOWebService_Default)); client = new PersonifySSOWebService.SimpleWebServiceSoapClient(basicHttpBinding, endpointAddress); if (client.State == System.ServiceModel.CommunicationState.Faulted) { client.Abort(); client = new PersonifySSOWebService.SimpleWebServiceSoapClient(basicHttpBinding, endpointAddress); } string timssSessionId = TimssSessionId; var procedure = await client.ExecuteStoredProcedureAsync(timssSessionId, spName, paramList, paramValueList).ConfigureAwait(true); if (procedure.Status) { XmlDocument xdocRes = new XmlDocument(); xdocRes.LoadXml(procedure.ResultSet); myDataSet.ReadXml(new XmlNodeReader(xdocRes)); } client.Abort(); client = null; return(myDataSet); } catch (TimeoutException ex) { string error = ex.Message; if (client != null) { client.Abort(); } throw; } catch (FaultException <string> ex) { string error = ex.Message; if (client != null) { client.Abort(); } throw; } catch (FaultException ex) { string error = ex.Message; if (client != null) { client.Abort(); } throw; } catch (CommunicationException ex) { string error = ex.Message + ex.StackTrace; if (client != null) { client.Abort(); } throw; } catch (Exception ex) { string error = ex.Message; if (client != null) { client.Abort(); } throw; } }