Beispiel #1
0
        private static void SoapClientProxy()
        {
            //init web service proxy
            PatientServiceProxy serviceProxy = new PatientServiceProxy();

            //init UsernameToken, password is the reverted string of username, the same logic in AuthenticateToken
            //  of ServiceUsernameTokenManager class.
            UsernameToken token = new UsernameToken("pas-appt-ws-user", "pas-appt-ws-user-pwd", PasswordOption.SendPlainText);

            // Set the token onto the proxy
            serviceProxy.SetClientCredential(token);

            // Set the ClientPolicy onto the proxy
            serviceProxy.SetPolicy("ClientPolicy");

            //invoke the HelloMyFriend web service method
            try
            {
                var res = serviceProxy.searchHKPMIPatientByCaseNo(new WebProxy.searchHKPMIPatientByCaseNo
                {
                    caseNo       = "HN03191100Y",
                    hospitalCode = "HV"
                });

                var resStr = XmlHelper.XmlSerializeToString(res);
                Console.WriteLine(resStr);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        public Models.PatientDemoEnquiry GetPatientResult(string caseNumber)
        {

            //init UsernameToken, password is the reverted string of username, the same logic in AuthenticateToken
            //  of ServiceUsernameTokenManager class.
            UsernameToken token = new UsernameToken(userName, password, PasswordOption.SendPlainText);

            patientServiceProxy.SetClientCredential(token);

            patientServiceProxy.SetPolicy("ClientPolicy");

            var res = patientServiceProxy.searchHKPMIPatientByCaseNo(new WebProxy.searchHKPMIPatientByCaseNo
            {
                caseNo = caseNumber,
                hospitalCode = pathospcode
            });

            return XmlHelper.XmlDeserialize<Models.PatientDemoEnquiry>(XmlHelper.XmlSerializeToString(res.PatientDemoEnquiryResult));
        }