在c#中获取FedEx的跟踪状态代码

时间:2016-08-03 04:56:37

标签: c# fedex

我已经看到了在Fedex api中获取fedex状态代码的代码,如下所示

private static TrackRequest CreateTrackRequest()
{
TrackRequest request = new TrackRequest();

request.WebAuthenticationDetail = new WebAuthenticationDetail();
request.WebAuthenticationDetail.UserCredential = new WebAuthenticationCredential();
request.WebAuthenticationDetail.UserCredential.Key = "1VMyaPNs9qWlnF82"; // Replace "XXX" with the Key
request.WebAuthenticationDetail.UserCredential.Password = "5HNNnnd8eNESISRsBigK9rmon"; // Replace "XXX" with the Password
request.WebAuthenticationDetail.ParentCredential = new WebAuthenticationCredential();
request.WebAuthenticationDetail.ParentCredential.Key = "1VMyaPNs9qWlnF82"; // Replace "XXX" with the Key
request.WebAuthenticationDetail.ParentCredential.Password = "5HNNnnd8eNESISRsBigK9rmon"; // Replace "XXX"

request.ClientDetail = new ClientDetail();
request.ClientDetail.AccountNumber = "510087860"; // Replace "XXX" with the client's account number
request.ClientDetail.MeterNumber = "100300728"; // Replace "XXX" with the client's meter number

request.TransactionDetail = new TransactionDetail();
request.TransactionDetail.CustomerTransactionId = "any value";  //This is a reference field for the customer.  Any value can be used and will be provided in the response.

request.Version = new VersionId();

request.SelectionDetails = new TrackSelectionDetail[1] { new TrackSelectionDetail() };
request.SelectionDetails[0].PackageIdentifier = new TrackPackageIdentifier();
request.SelectionDetails[0].PackageIdentifier.Value = "123456789012"; // Replace "XXX" with tracking number or door tag

request.SelectionDetails[0].PackageIdentifier.Type = TrackIdentifierType.TRACKING_NUMBER_OR_DOORTAG;
request.SelectionDetails[0].ShipDateRangeBeginSpecified = false;
request.SelectionDetails[0].ShipDateRangeEndSpecified = false;

return request;
}
static void Main(string[] args)
{
TrackRequest request = CreateTrackRequest();
TrackService service = new TrackService();
TrackReply reply = service.track(request);
foreach (CompletedTrackDetail completedTrackDetail in reply.CompletedTrackDetails)
{
    foreach (TrackDetail trackDetail in completedTrackDetail.TrackDetails)
    {
        Console.WriteLine("Track Status: {0} ({1})", trackDetail.StatusDetail.Description, trackDetail.StatusDetail.Code);
    }
}
}

它包含foreach循环以获取每个已完成的跟踪详细信息并获取每个状态。 我们如何获得跟踪号码的单一状态代码?

0 个答案:

没有答案