VB.NET SOAP GetReports

    //VB.NET SOAP GetReports with ServiceReference to WSDL -http://pcmiler.alk.com/apis/soap/v1.0/service.svc?wsdl
  
        Dim apiK As String = apiKey.Text
        Dim dataVer As String = ListBox1.SelectedItem

        If (apiK <> "") Then
           
            Dim rr As New ReportRoute() With {
              .Stops = New StopLocation(1) {}
            }
            Dim listr As New List(Of ReportRoute)()

            'If zip is in both US &amp; Mex, you need to specify US or if you want MX use MX for CountryPostalFilter
            'Stops can be entered with city/state or zip or city/state/zip combo or lat/long
            rr.Stops(0) = New StopLocation() With {
                .Address = New Address() With {
                    .City = "Princeton",
                    .State = "NJ",
                    .Zip = "08540",
                    .CountryPostalFilter = PostCodeType.US,
            .CountryPostalFilterSpecified = True
            },
               .Label = "Princeton",
              .Region = DataRegion.NA,
              .RegionSpecified = True
            }
            rr.Stops(1) = New StopLocation() With {
            .Address = New Address() With {
             .City = "Bensalem",
             .State = "PA",
             .Zip = "19020"
           },
            .Label = "Bensalem",
            .Region = DataRegion.NA,
            .RegionSpecified = True
          }
       rr.ReportTypes = New ReportType(0) {}
                rr.ReportTypes(0) = New MileageReportType()
            '   rr.ReportTypes(1) = New CalculateMilesReportType()
            '  rr.ReportTypes(2) = New DetailReportType()
            ' rr.ReportTypes(3) = New StateReportType()
            'rr.ReportTypes(4) = New RoadReportType()
            'rr.ReportTypes(5) = New LeastCostReportType()
            'rr.ReportTypes(6) = New DirectionsReportType()
      
      
       rr.Options = New RouteOptions() With {
              .HighwayOnly = True,
              .HubRouting = False,
              .HighwayOnlySpecified = True,
              .DistanceUnits = DistanceUnits.Miles,
              .VehicleType = VehicleType.Truck,
              .VehicleTypeSpecified = True
            }

            rr.ReportingOptions = New ReportOptions() With {
              .UseTollData = False,
              .UseTollDataSpecified = False
            }

            listr.Add(rr)

            Dim servReq As New ReportRequest() With {
              .Header = New RequestHeader() With {
               .RequestType = "GetReports",
               .DataVersion = "current"
             },
              .Body = New ReportRequestBody()
            }

            servReq.Body.ReportRoutes = listr.ToArray()


            Dim auth As New AuthHeader()
            auth.Authorization = apiKey.Text

            auth.[Date] = DateTime.Now.ToString("r")
        
            Dim service As New ServiceClient()
         
            Dim rsp As ReportResponse = service.GetReports(auth, servReq)
            Dim mr As MileageReport = rsp.Body.Reports(0)
            Dim rptLen = mr.ReportLines.Length()
            Dim totMiles = mr.ReportLines(rptLen - 1).TMiles
            Dim totTime = mr.ReportLines(rptLen - 1).THours
      Else
            MessageBox.Show("Please Enter All Fields")
        End If



This sample may use features that are only available in our Premium WebServices. Please refer to our Features page to confirm what feature level you currently subscribe to.