Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 175
  • Last Modified:

ups web service

I have below web service in Vb. It is very old codes for UPS web services. I can build it in VB studio without any errors and issues. But no result. And I find out there is no parameter for UPS license number. And see anyone can help me to valid it is still working.

Thanks

<%@ WebService language="VB" class="UPS" %>
imports system
imports system.web
imports System.Net
imports System.IO
imports System.Web.Services
Imports Microsoft.VisualBasic

Public Class UPS : Inherits System.Web.Services.WebService

 <WebMethod()> _
 Public Function GetPrice(SvcCode as String,RateChart as String,ShipperZIP as String,ReceiverZIP as String, _
                          ReceiverCountry as String,PkgWeight as String,IsResidential as String,IsCOD as String, _
                          IsSatPickup as String,IsSatDelivery as String,PkgType as String) as string
        Dim sReturn As String = ""
        Dim WebReq As WebRequest
        Dim WebResp As WebResponse
        Dim strStream As StreamReader
        Dim URLRequest As String
        Dim line As String

        URLRequest = BuildUPSRequest(SvcCode, RateChart, ShipperZIP, ReceiverZIP, "US", PkgWeight, IsResidential, IsCOD, IsSatPickup, IsSatDelivery, PkgType)

        WebReq = WebRequest.Create(URLRequest)
        'WebReq.KeepAlive = false
        WebResp = WebReq.GetResponse()
        strStream = New StreamReader(WebResp.GetResponseStream(), System.Text.Encoding.ASCII)
        Try
            line = strStream.ReadLine()
            Do While line <> ""
                line = strStream.ReadLine()
                If instr(1, lcase(line), "upsonline") <> 0 Then
                    Dim strArrayData() As String
                    strArrayData = Split(line, "%")
                    If left(strArrayData(3), 4) = "0000" Then
                        sReturn = strArrayData(12)
                    Else
                        sReturn = "ERR : " & right(strArrayData(3), len(strArrayData(3)) - 4)
                    End If
                    Exit Do
                End If
            Loop
        Catch ex As Exception
            sReturn = ex.Message
        End Try
        Return sReturn
    End Function
 
    Private Function BuildUPSRequest(SvcCode As String, RateChart As String, ShipperZIP As String, ReceiverZIP As String, _
                            ReceiverCountry As String, PkgWeight As String, IsResidential As String, IsCOD As String, _
                            IsSatPickup As String, IsSatDelivery As String, PkgType As String) As String

        Dim UPSPayload As String
        UPSPayload = ""
        UPSPayload = "http://www.ups.com/using/services/rave/qcost_dss.cgi?"
        UPSPayload = UPSPayload & "AppVersion=1.2&AcceptUPSLicenseAgreement=YES&"
        UPSPayload = UPSPayload & "ResponseType=application/x-ups-rss&ActionCode=3&"
        UPSPayload = UPSPayload & "ServiceLevelCode=" & SvcCode & "&RateChart=" & RateChart & "&"
        UPSPayload = UPSPayload & "ShipperPostalCode=" & ShipperZIP & "&ConsigneePostalCode=" & ReceiverZIP & "&"
        UPSPayload = UPSPayload & "ConsigneeCountry=" & ReceiverCountry & "&PackageActualWeight=" & PkgWeight & "&"
        UPSPayload = UPSPayload & "ResidentialInd=" & IsResidential & "&CODInd=" & IsCOD & "&SatDelivInd=" & IsSatDelivery
        UPSPayload = UPSPayload & "&SatPickupInd=" & IsSatPickup & "&PackagingType=" & PkgType
        Return UPSPayload
    End Function

End Class
0
ITsolutionWizard
Asked:
ITsolutionWizard
  • 3
  • 2
1 Solution
 
Bob LearnedCommented:
UPS has a few web services (Shipping API, Tracking API, Rating API, ...).  What API are you working with?

What UPS APIs are Available?
http://www.ups.com/content/us/en/resources/sri/apidefinition.html
0
 
ITsolutionWizardAuthor Commented:
Rating
0
 
Bob LearnedCommented:
Things have changed since I last used UPS.  I find here that you have to login to see the API documentation.

UPS Developer Kit
https://www.ups.com/upsdeveloperkit/downloadresource?loc=en_US

You must Log-in to download the API documentation.
0
 
ITsolutionWizardAuthor Commented:
I need codes for rating not a link
0
 
Bob LearnedCommented:
I am trying to tell you that I can't help you.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now