troubleshooting Question

vb to ASP or ASP.NET

Avatar of webdork
webdork asked on
Scripting Languages
1 Comment1 Solution716 ViewsLast Modified:
I'm an experienced classic asp developer.  I'm trying to move into .NET.  I've got the attached vb file from FED EX.  How can I convert this to a web ready file?
Option Strict Off
Option Explicit On
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Collections
Imports System.Web.Services.Protocols
Imports RateWebServiceClient.RateWebReference
' Sample code to call the FedEx Rate v5 Web Service
' Tested with Microsoft Visual Studio 2005 professional Edition
Module Module1
    Sub Main()
        Dim request As RateRequest = New RateRequest() ' Build a RateRequest object
        request.WebAuthenticationDetail = New WebAuthenticationDetail()
        request.WebAuthenticationDetail.UserCredential = New WebAuthenticationCredential()
        request.WebAuthenticationDetail.UserCredential.Key = "XXX" ' Replace "XXX" with the Key
        request.WebAuthenticationDetail.UserCredential.Password = "XXX" ' Replace "XXX" with the Password
        request.ClientDetail = New ClientDetail()
        request.ClientDetail.AccountNumber = "XXX" ' Replace "XXX" with clients account number
        request.ClientDetail.MeterNumber = "XXX" ' Replace "XXX" with clients meter number
        request.TransactionDetail = New TransactionDetail()
        request.TransactionDetail.CustomerTransactionId = "*** Rate Request v6 using VB.NET ***" ' This is a reference field for the customer.  Any value can be used and will be provided in the response.
        request.Version = New VersionId() ' WSDL version information, value is automatically set from wsdl        
        request.RequestedShipment = New RequestedShipment()
        request.RequestedShipment.ShipTimestamp = DateTime.Now ' Ship date and time
        request.RequestedShipment.DropoffType = DropoffType.REGULAR_PICKUP
        request.RequestedShipment.ServiceType = ServiceType.PRIORITY_OVERNIGHT ' Service types are STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND ...
        request.RequestedShipment.PackagingType = PackagingType.YOUR_PACKAGING ' Packaging type FEDEX_BOK, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ...
        request.RequestedShipment.TotalWeight = New Weight() ' Total weight information
        request.RequestedShipment.TotalWeight.Value = 50.0
        request.RequestedShipment.TotalWeight.Units = WeightUnits.LB
        request.RequestedShipment.Shipper = New Party() ' Sender information
        request.RequestedShipment.Shipper.Contact = New Contact()
        request.RequestedShipment.Shipper.Contact.PersonName = "Sender Name"
        request.RequestedShipment.Shipper.Contact.CompanyName = "Sender Company Name"
        request.RequestedShipment.Shipper.Contact.PhoneNumber = "0805522713"
        request.RequestedShipment.Shipper.Address = New Address()
        request.RequestedShipment.Shipper.Address.StreetLines = New String(0) {"Address Line 1"}
        request.RequestedShipment.Shipper.Address.City = "Irving"
        request.RequestedShipment.Shipper.Address.StateOrProvinceCode = "TX"
        request.RequestedShipment.Shipper.Address.PostalCode = "75063"
        request.RequestedShipment.Shipper.Address.CountryCode = "US"
        request.RequestedShipment.Recipient = New Party() ' Recipient information
        request.RequestedShipment.Recipient.Contact = New Contact()
        request.RequestedShipment.Recipient.Contact.PersonName = "Recipient Name"
        request.RequestedShipment.Recipient.Contact.CompanyName = "Recipient Company Name"
        request.RequestedShipment.Recipient.Contact.PhoneNumber = "9012637906"
        request.RequestedShipment.Recipient.Address = New Address()
        request.RequestedShipment.Recipient.Address.StreetLines = New String(0) {"Address Line 1"}
        request.RequestedShipment.Recipient.Address.City = "Connecticut"
        request.RequestedShipment.Recipient.Address.StateOrProvinceCode = "CT"
        request.RequestedShipment.Recipient.Address.PostalCode = "06006"
        request.RequestedShipment.Recipient.Address.CountryCode = "US"
        request.RequestedShipment.Recipient.Address.Residential = True
        request.RequestedShipment.ShippingChargesPayment = New Payment() ' Payment information
        request.RequestedShipment.ShippingChargesPayment.PaymentType = PaymentType.SENDER
        request.RequestedShipment.ShippingChargesPayment.Payor = New Payor()
        request.RequestedShipment.ShippingChargesPayment.Payor.AccountNumber = "XXX" ' Replace "XXX" with clients account number
        request.RequestedShipment.ShippingChargesPayment.Payor.CountryCode = "US"
        Dim bCodShipment As Boolean
        bCodShipment = False ' set to true to request COD shipment and print COD return label
        If (bCodShipment) Then
            request.RequestedShipment.SpecialServicesRequested = New ShipmentSpecialServicesRequested() ' Special service requested
            request.RequestedShipment.SpecialServicesRequested.SpecialServiceTypes = New ShipmentSpecialServiceType(0) {ShipmentSpecialServiceType.COD} ' Special Services types COD, HOLD_AT_LOCATION, RESIDENTIAL DELIVERY, ...
            request.RequestedShipment.SpecialServicesRequested.CodDetail = New CodDetail()
            request.RequestedShipment.SpecialServicesRequested.CodDetail.CollectionType = CodCollectionType.ANY ' ANY, CASH, GUARANTEED_FUNDS
            request.RequestedShipment.SpecialServicesRequested.CodCollectionAmount = New Money()
            request.RequestedShipment.SpecialServicesRequested.CodCollectionAmount.Amount = 150
            request.RequestedShipment.SpecialServicesRequested.CodCollectionAmount.Currency = "USD"
        End If
        request.RequestedShipment.RateRequestTypes = New RateRequestType(0) {RateRequestType.ACCOUNT} ' Rate types requested LIST, MULTIWEIGHT, ...
        request.RequestedShipment.PackageCount = 1
        request.RequestedShipment.RequestedPackages = New RequestedPackage(0) {New RequestedPackage()}
        request.RequestedShipment.RequestedPackages(0).SequenceNumber = 1
        request.RequestedShipment.RequestedPackages(0).Weight = New Weight() ' Package weight information
        request.RequestedShipment.RequestedPackages(0).Weight.Value = 50.0
        request.RequestedShipment.RequestedPackages(0).Weight.Units = WeightUnits.LB
        Dim rateService As RateService = New RateService() ' Initialize the service
            ' This is the call to the web service passing in a RateRequest and returning a RateReply
            Dim reply As RateReply = rateService.getRates(request) ' Service call
            If ((Not reply.HighestSeverity = NotificationSeverityType.ERROR) And (Not reply.HighestSeverity = NotificationSeverityType.FAILURE)) Then ' check if the call was successful
                If (Not reply.RateReplyDetails(0) Is Nothing) And (Not reply.RateReplyDetails(0).RatedShipmentDetails Is Nothing) Then
                    Dim j As Integer = 1
                    For Each ratedShipmentDetail As RatedShipmentDetail In reply.RateReplyDetails(0).RatedShipmentDetails
                        Console.WriteLine("---Rated Shipment Detail for Rate Type {0}---", j) 'Shipment and package rates for each Rate Type 
                        If (Not ratedShipmentDetail.ShipmentRateDetail Is Nothing) Then
                            Console.WriteLine("Rate Type : " + ratedShipmentDetail.ShipmentRateDetail.RateType.ToString)
                            Console.WriteLine("--- Shipment Rate Detail ---")
                            If (Not ratedShipmentDetail.ShipmentRateDetail.TotalBillingWeight Is Nothing) Then ' Total weight of all packages
                                Console.WriteLine("Total billing weight {0} {1}", ratedShipmentDetail.ShipmentRateDetail.TotalBillingWeight.Value, ratedShipmentDetail.ShipmentRateDetail.TotalBillingWeight.Units)
                            End If
                            If (Not ratedShipmentDetail.ShipmentRateDetail.TotalSurcharges Is Nothing) Then ' Total Surcharges for all packages
                                Console.WriteLine("    Total surcharges {0} {1}", ratedShipmentDetail.ShipmentRateDetail.TotalSurcharges.Amount, ratedShipmentDetail.ShipmentRateDetail.TotalSurcharges.Currency)
                            End If
                            If (Not ratedShipmentDetail.ShipmentRateDetail.TotalNetCharge Is Nothing) Then ' TotalNetCharge is the Rate plus all surcharges for all packages
                                Console.WriteLine("    Total net charge {0} {1}", ratedShipmentDetail.ShipmentRateDetail.TotalNetCharge.Amount, ratedShipmentDetail.ShipmentRateDetail.TotalNetCharge.Currency)
                            End If
                        End If
                        If (Not ratedShipmentDetail.RatedPackages Is Nothing) Then
                            ' This is weight, and charge per package
                            Console.WriteLine("--- Rated Package Detail ---")
                            Dim p As Integer = 1
                            For Each ratedPackage As RatedPackageDetail In ratedShipmentDetail.RatedPackages
                                If (Not ratedPackage.PackageRateDetail Is Nothing) Then
                                    Console.WriteLine("Package {0}", p)
                                    Console.WriteLine("Billing weight {0} {1}", ratedPackage.PackageRateDetail.BillingWeight.Value, ratedPackage.PackageRateDetail.BillingWeight.Units)
                                    Console.WriteLine("   Base charge {0} {1}", ratedPackage.PackageRateDetail.BaseCharge.Amount, ratedPackage.PackageRateDetail.BaseCharge.Currency)
                                    For Each surcharge As Surcharge In ratedPackage.PackageRateDetail.Surcharges
                                        Console.WriteLine("{0} surcharge {1} {2}", surcharge.SurchargeType.ToString(), surcharge.Amount.Amount, surcharge.Amount.Currency)
                                    Console.WriteLine("    Net charge {0} {1}", ratedPackage.PackageRateDetail.NetCharge.Amount, ratedPackage.PackageRateDetail.NetCharge.Currency)
                                    p = p + 1
                                End If
                            j = j + 1
                        End If
                End If
                For Each notification As Notification In reply.Notifications
            End If
        Catch e As SoapException
        Catch e As Exception
        End Try
        Console.WriteLine("Press any key to quit !")
    End Sub
End Module

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros