/// <summary> /// Gets the tracking method. /// </summary> /// <returns>TrackingReturnType</returns> /// <param name="trackingcode">Trackingcode.</param> private static TrackingReturnType GetTrackingMethod(string trackingcode) { TrackingReturnType trackingDetail = new TrackingReturnType(); Service = GetAuthoriseService(); try { // Call the GetDomesticAddressByKey soap service trackingDetail = Service.GetTracking(trackingcode); } catch (Exception soapEx) { Console.WriteLine("{0}", soapEx.Message); throw; } return(trackingDetail); }
/// <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 TrackingService GetAuthoriseService() { // Set up some credentials NetworkCredential netCredential = new NetworkCredential(apiuser, apikey); // Create the service of type Tracking service TrackingService Service = new TrackingService(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); }