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 TotalInvoice As System.Web.UI.WebControls.Label
Protected WithEvents Rate1 As System.Web.UI.WebControls.Label
Protected WithEvents OriginManager 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 RateRequest As System.Text.StringBuilder = New System.Text.StringBuilder
RateRequest.Append("<Create>")
RateRequest.Append("<UserID>Your User ID</UserID>")
RateRequest.Append("<Password>Your Password</Password>")
RateRequest.Append("<TestMode>Y</TestMode>")
RateRequest.Append("<BillingTerms>Prepaid</BillingTerms>")
RateRequest.Append("<AccountNumber>0123456</AccountNumber>")
' Outbound
RateRequest.Append("<Application>Outbound</Application>")
RateRequest.Append("<DestinationCity>LOS ANGELES</DestinationCity>")
RateRequest.Append("<DestinationState>CA</DestinationState>")
RateRequest.Append("<DestinationZipcode>90001</DestinationZipcode>")
' Inbound
'RateRequest.Append("<Application>Inbound</Application>")
'RateRequest.Append("<OriginCity>LOS ANGELES</OriginCity>")
'RateRequest.Append("<OriginState>CA</OriginState>")
'RateRequest.Append("<OriginZipcode>90001</OriginZipcode>")
' ThirdParty
'RateRequest.Append("<Application>ThirdParty</Application>")
'RateRequest.Append("<OriginCity>HOUMA</OriginCity>")
'RateRequest.Append("<OriginState>LA</OriginState>")
'RateRequest.Append("<OriginZipcode>70364</OriginZipcode>")
'RateRequest.Append("<DestinationCity>LOS ANGELES</DestinationCity>")
'RateRequest.Append("<DestinationState>CA</DestinationState>")
'RateRequest.Append("<DestinationZipcode>90001</DestinationZipcode>")
RateRequest.Append("<Details>")
RateRequest.Append("<DetailItem>")
RateRequest.Append("<Weight>100</Weight>")
RateRequest.Append("<Class>50</Class>")
RateRequest.Append("</DetailItem>")
RateRequest.Append("</Details>")
RateRequest.Append("<Accessorials>")
RateRequest.Append("<AccessorialItem>")
RateRequest.Append("<Code>LiftgateService</Code>")
RateRequest.Append("</AccessorialItem>")
RateRequest.Append("</Accessorials>")
RateRequest.Append("</Create>")
Try
Dim http As System.Net.HttpWebRequest = System.Net.WebRequest.Create("http://www.saiasecure.com/webservice/ratequote/xml.aspx")
http.Method = "POST"
http.ContentLength = RateRequest.ToString().Length
http.ContentType = "text/xml"
Dim sw As System.IO.StreamWriter = New System.IO.StreamWriter(http.GetRequestStream())
sw.Write(RateRequest.ToString())
sw.Close()
Dim RateResponse As String
Dim httpResponse As System.Net.HttpWebResponse = http.GetResponse()
Dim sr As System.IO.StreamReader = New System.IO.StreamReader(httpResponse.GetResponseStream())
RateResponse = sr.ReadToEnd()
sr.Close()
Dim XmlResponse As System.Xml.XmlDocument = New System.Xml.XmlDocument
XmlResponse.LoadXml(RateResponse)
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.TotalInvoice.Text = XmlResponse.SelectSingleNode("/Response/TotalInvoice").InnerText
Me.OriginManager.Text = XmlResponse.SelectSingleNode("/Response/OriginTerminal/Manager").InnerText
' Below is a sample of how to retrieve an array
' using XPath and XML with SelectNodes().
Dim RateDetails As System.Xml.XmlNodeList = XmlResponse.SelectNodes("/Response/RateDetails/RateDetailItem")
For Each RateDetailItem As System.Xml.XmlNode In RateDetails
Rate1.Text = RateDetailItem("Rate").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.