Solved

ups web service

Posted on 2014-11-06
5
143 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

772 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