Beispiel #1
0
        public AddressWebService()
        {
            var conf       = SecurityAccessor.Instance.EncryptConfig;
            var addressEsb = conf.GetAddressESBService();

            client      = new AddressService.addressServicePortClient(conf.DecryptValue(addressEsb.EndPointName), conf.DecryptValue(addressEsb.Uri));
            reply       = null;
            request     = null;
            addrReply   = null;
            addrRequest = null;
        }
Beispiel #2
0
        public bool validateAddress(string strAddress1, string strAddress2, string strCity, string strState)
        {
            bool addrCheck = false;

            try
            {
                var conf       = SecurityAccessor.Instance.EncryptConfig;
                var addressEsb = conf.GetAddressESBService();
                addrRequest = new AddressService.addressValidationRequestType();
                addrRequest.serviceInformation           = new AddressService.serviceInformationType();
                addrRequest.serviceInformation.domain    = conf.DecryptValue(addressEsb.Domain);
                request.serviceInformation.shopNumber    = ShopNumber;
                request.serviceInformation.terminalID    = TerminalID;
                request.serviceInformation.userID        = UserID;
                request.serviceInformation.transactionID = TransactionID;
                request.serviceInformation.timeStamp     = CurrentDateTime;
                addrRequest.serviceData = new AddressService.addressValidationRequestTypeServiceData();
                string[] strStreet;
                if (strAddress2.Trim().Length > 0)
                {
                    strStreet    = new string[2];
                    strStreet[0] = strAddress1;
                    strStreet[1] = strAddress2;
                }
                else
                {
                    strStreet    = new string[1];
                    strStreet[0] = strAddress1;
                }

                addrRequest.serviceData.address = new AddressService.addressType
                {
                    street = strStreet,
                    city   = strCity,
                    state  = strState,
                    type   = AddressService.addressTypeType.PHYSICAL
                };

                client.Open();
                addrReply = client.validateAddress(addrRequest);
                client.Close();
                var returnedAddress = (AddressService.addressType)reply.serviceData.Item;
                if (returnedAddress.postalCode.zipCode != null)
                {
                    addrCheck = true;
                }
                else
                {
                    addrCheck = false;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                client  = null;
                request = null;
                reply   = null;
            }
            return(addrCheck);
        }