Solved

ups web service

Posted on 2014-11-06
5
130 Views
Last Modified: 2014-11-20
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
Comment
Question by:ITsolutionWizard
  • 3
  • 2
5 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 40428627
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
 

Author Comment

by:ITsolutionWizard
ID: 40428770
Rating
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 40429173
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
 

Author Comment

by:ITsolutionWizard
ID: 40429319
I need codes for rating not a link
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 40429358
I am trying to tell you that I can't help you.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now