Sample Application Code

Public Class WebForm1
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
     Private Sub InitializeComponent()

    End Sub
    Protected WithEvents Element As System.Web.UI.WebControls.Label
    Protected WithEvents Label3 As System.Web.UI.WebControls.Label
    Protected WithEvents Label1 As System.Web.UI.WebControls.Label
    Protected WithEvents Label2 As System.Web.UI.WebControls.Label
    Protected WithEvents ResponseCode As System.Web.UI.WebControls.Label
    Protected WithEvents Label5 As System.Web.UI.WebControls.Label
    Protected WithEvents Fault As System.Web.UI.WebControls.Label
    Protected WithEvents Label7 As System.Web.UI.WebControls.Label
    Protected WithEvents Message As System.Web.UI.WebControls.Label
    Protected WithEvents Label9 As System.Web.UI.WebControls.Label
    Protected WithEvents CurrentStatus As System.Web.UI.WebControls.Label
    Protected WithEvents ConsigneeName As System.Web.UI.WebControls.Label
    Protected WithEvents Description1 As System.Web.UI.WebControls.Label

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim ShipmentRequest As System.Text.StringBuilder = New System.Text.StringBuilder

        ShipmentRequest.Append("<GetByProNumber>")
        ShipmentRequest.Append("<UserID>Your User ID</UserID>")
        ShipmentRequest.Append("<Password>Your Password</Password>")
        ShipmentRequest.Append("<TestMode>Y</TestMode>")
        ShipmentRequest.Append("<ProNumber>463510000</ProNumber>")
        ShipmentRequest.Append("</GetByProNumber>")

        ' Below are examples of the other tracing request documents.

        ' GetByBLNumber
        'ShipmentRequest.Append("<GetByBLNumber>")
        'ShipmentRequest.Append("<UserID>Your User ID</UserID>")
        'ShipmentRequest.Append("<Password>Your Password</Password>")
        'ShipmentRequest.Append("<TestMode>Y</TestMode>")
        'ShipmentRequest.Append("<BLNumber>12345</BLNumber>")
        'ShipmentRequest.Append("<OriginZipcode>38101</OriginZipcode>")
        'ShipmentRequest.Append("<DestinationZipcode>70364</DestinationZipcode>")
        'ShipmentRequest.Append("</GetByBLNumber>")

        ' GetByPONumber
        'ShipmentRequest.Append("<GetByPONumber>")
        'ShipmentRequest.Append("<UserID>Your User ID</UserID>")
        'ShipmentRequest.Append("<Password>Your Password</Password>")
        'ShipmentRequest.Append("<TestMode>Y</TestMode>")
        'ShipmentRequest.Append("<PONumber>12345</PONumber>")
        'ShipmentRequest.Append("<OriginZipcode>38101</OriginZipcode>")
        'ShipmentRequest.Append("<DestinationZipcode>70364</DestinationZipcode>")
        'ShipmentRequest.Append("</GetByPONumber>")

        ' GetByShipperNumber
        'ShipmentRequest.Append("<GetByShipperNumber>")
        'ShipmentRequest.Append("<UserID>Your User ID</UserID>")
        'ShipmentRequest.Append("<Password>Your Password</Password>")
        'ShipmentRequest.Append("<TestMode>Y</TestMode>")
        'ShipmentRequest.Append("<ShipperNumber>12345</ShipperNumber>")
        'ShipmentRequest.Append("<OriginZipcode>38101</OriginZipcode>")
        'ShipmentRequest.Append("<DestinationZipcode>70364</DestinationZipcode>")
        'ShipmentRequest.Append("</GetByShipperNumber>")

        ' GetByPartnerNumber
        'ShipmentRequest.Append("<GetByPartnerNumber>")
        'ShipmentRequest.Append("<UserID>Your User ID</UserID>")
        'ShipmentRequest.Append("<Password>Your Password</Password>")
        'ShipmentRequest.Append("<TestMode>Y</TestMode>")
        'ShipmentRequest.Append("<PartnerSCAC>VITR</PartnerSCAC>")
        'ShipmentRequest.Append("<PartnerNumber>123456789</PartnerNumber>")
        'ShipmentRequest.Append("</GetPartnerNumber>")

        Try

            Dim http As System.Net.HttpWebRequest = System.Net.WebRequest.Create("http://www.saiasecure.com/webservice/shipment/xml.aspx")
            http.Method = "POST"
            http.ContentLength = ShipmentRequest.ToString().Length
            http.ContentType = "text/xml"
            Dim sw As System.IO.StreamWriter = New System.IO.StreamWriter(http.GetRequestStream())
            sw.Write(ShipmentRequest.ToString())
            sw.Close()

            Dim ShipmentResponse As String
            Dim httpResponse As System.Net.HttpWebResponse = http.GetResponse()
            Dim sr As System.IO.StreamReader = New System.IO.StreamReader(httpResponse.GetResponseStream())
            ShipmentResponse = sr.ReadToEnd()
            sr.Close()

            Dim XmlResponse As System.Xml.XmlDocument = New System.Xml.XmlDocument
            XmlResponse.LoadXml(ShipmentResponse)

            If XmlResponse.SelectSingleNode("/Response/Code").InnerText <> "" Then

                ' Add error handling code in case Saia responds 
                ' with an Error Code

                Me.ResponseCode.Text = XmlResponse.SelectSingleNode("/Response/Code").InnerText
                Me.Element.Text = XmlResponse.SelectSingleNode("/Response/Element").InnerText
                Me.Fault.Text = XmlResponse.SelectSingleNode("/Response/Fault").InnerText
                Me.Message.Text = XmlResponse.SelectSingleNode("/Response/Message").InnerText

            Else

                Me.CurrentStatus.Text = XmlResponse.SelectSingleNode("/Response/CurrentStatus").InnerText
                Me.ConsigneeName.Text = XmlResponse.SelectSingleNode("/Response/Consignee/Name").InnerText

                ' Below is a sample of how to retrieve an array
                ' using XPath and XML with SelectNodes().

                Dim Details As System.Xml.XmlNodeList = XmlResponse.SelectNodes("/Response/Details/DetailItem")

                For Each DetailItem As System.Xml.XmlNode In Details

                    Description1.Text = DetailItem("Description").InnerText
                    Exit For

                Next

            End If

        Catch

            ' Add error handling code in case your unable to connect 
            ' to the Saia Website.

        End Try

    End Sub

End Class


Disclaimer:

Saia Inc. authorizes the use of these Web Services solely to facilitate the exchange of information between Saia and the customer. Unauthorized use of Saia, Inc. Web Services and information is strictly prohibited. All services may be used for lawful purposes only. No warranty, express or implied, is given relating to the accuracy of content and Saia, Inc. does not accept any liability for error or omission.

Saia Inc. reserves the right to refuse or cancel these services at it’s sole discretion. If any terms or conditions are failed to be followed, results constitute grounds for immediate account deactivation.