示例#1
0
        public AddressingService AuthenticateWithDespatchBay(AddressingService Service)
        {
            // Create the service of type Shipping service

            Service.RequestEncoding = System.Text.Encoding.UTF8;
            Uri          uri         = new Uri(Service.Url);
            ICredentials credentials = SetAuthType(uri);

            // Apply the credentials to the service
            Service.Credentials = credentials;
            return(Service);
        }
 /// <summary>
 /// Gets the domestic address keys by postcode method.
 /// </summary>
 /// <returns>The domestic address keys by postcode method.</returns>
 /// <param name="postcode">Postcode.</param>
 private static AddressKeyType[] GetAddressKeysByPostcodeMethod(string postcode)
 {
     AddressKeyType[] availableAddresses;
     Service = GetAuthoriseService();
     try {
         // Call the GetDomesticAddressKeysByPostcode soap service
         availableAddresses = Service.GetAddressKeysByPostcode(postcode);
     } catch (Exception soapEx) {
         Console.WriteLine("{0}", soapEx.Message);
         throw;
     }
     return(availableAddresses);
 }
示例#3
0
        /// <summary>
        /// Gets the authorise service. Loads a XML configuration file, creates a
        /// Basic Auth credentioals object and applies to the Service we want to use
        /// </summary>
        /// <returns>The authorise service.</returns>
        static AddressingService GetAuthoriseService()
        {
            // Set up some credentials
            NetworkCredential netCredential = new NetworkCredential(apiuser, apikey);
            // Create the service of type Addressing service
            AddressingService Service = new AddressingService(apiendpoint);

            Service.RequestEncoding = System.Text.Encoding.UTF8;
            Uri          uri         = new Uri(Service.Url);
            ICredentials credentials = netCredential.GetCredential(uri, "Basic");

            // Apply the credentials to the service
            Service.Credentials = credentials;
            return(Service);
        }
        /// <summary>
        /// Finds the address method.
        /// </summary>
        /// <returns>The address method.</returns>
        /// <param name="postcode">Postcode.</param>
        /// <param name="place">Place.</param>
        private static AddressType FindAddressMethod(string postcode, string place)
        {
            AddressType Address = new AddressType();

            Service = GetAuthoriseService();
            try
            {
                // Call the GetDomesticAddressByKey soap service
                Address = Service.FindAddress(postcode, place);
            }
            catch (Exception soapEx)
            {
                Console.WriteLine("{0}", soapEx.Message);
                throw;
            }
            return(Address);
        }
示例#5
0
    /**
     * Name: GetDomesticAddressKeysByPostcodeMethod
     * Parameters: String postcode
     * Returns: Array of objects of type AddressKeyType
     * Throws an Exception of type SoapEx on failure
     *
     **/
    public AddressKeyType[] GetDomesticAddressKeysByPostcodeMethod(string postcode)
    {
        AddressKeyType[] availableAddresses = null;
        try
        {
            var Service = new AddressingService();
            Service = GetAuthoriseService(Service);
            // Call the GetDomesticAddressKeysByPostcode soap service
            availableAddresses = Service.GetDomesticAddressKeysByPostcode(postcode);
        }
        catch (Exception soapEx)
        {
            // Throw the generated exception up.
            throw soapEx;
        }

        return(availableAddresses);
    }
示例#6
0
 /**
  * Connects to the api endpoint, authorises and returns an AddressingService Object
  *
  **/
 public AddressingService GetAuthoriseService(AddressingService S)
 {
     S.Credentials = getCredentials(S.Url);         // credentials;
     return(S);
 }