Forum Moderators: open
Anyway, in my brief look, I couldn't tell how easy or hard it is, since I couldn't find the example of the transaction. If you have any pointers to documentation of what the XML request and response should look like, that would help.
<% Response.Buffer=True %>
<%
'dim all of our vars
Dim xml, xsl, template, processor, strXML'you can build the query dynamically by using request.form or request.querystring, however you want to use it
strXML = "<?xml version='1.0'?><AccessRequest xml:lang='en-US'><AccessLicenseNumber></AccessLicenseNumber><UserId></UserId><Password></Password></AccessRequest><?xml version='1.0'?><RatingServiceSelectionRequest xml:lang='en-US'><Request><TransactionReference><CustomerContext>Rating and Service</CustomerContext><XpciVersion>1.0001</XpciVersion></TransactionReference><RequestAction>Rate</RequestAction><RequestOption>shop</RequestOption></Request><PickupType><Code>01</Code></PickupType><Shipment><Shipper><Address><PostalCode>30076</PostalCode></Address></Shipper><ShipTo><Address><PostalCode>30041</PostalCode></Address></ShipTo><Service><Code>11</Code></Service><Package><PackagingType><Code>02</Code><Description>Package</Description></PackagingType><Description>Rate Shopping</Description><PackageWeight><Weight>33</Weight></PackageWeight></Package><ShipmentServiceOptions/></Shipment></RatingServiceSelectionRequest>"
'this will url encode your request
'strXML = Server.UrlEncode(strXML)
'here's where we send the stuff
Dim xmlhttp
Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "POST","https://www.ups.com/ups.app/xml/Rate?",false
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.send strXML
Response.Write(xmlhttp.responseText)
'we load into a multi thread object for xsl transformations
Set xml = Server.CreateObject("MSXML2.FreeThreadedDOMDocument.3.0")
xml.async = false
xml.loadXml(xmlhttp.responseText)
'start email success
Dim ObjMail, intMailFormat, strSubject
intMailFormat = 1
strSubject = "good response"
If Not xml Is Nothing Then
If Not xml.documentElement Is Nothing Then
'we are looking for the root node.
If xml.documentElement.nodeName = "RatingServiceSelectionResponse" Then
Set ObjMail = Server.CreateObject("CDONTS.NewMail")
ObjMail.FROM = ""
ObjMail.TO = ""
ObjMail.Subject = strSubject
ObjMail.BodyFormat = intMailFormat
ObjMail.Body = "Your request." & vbcrlf & strXML & vbcrlf & "Your response." & vbcrlf & xmlhttp.responseText
ObjMail.Send
Set ObjMail = Nothing
End If
End If
End If
'load our xsl
Set xsl = Server.CreateObject("MSXML2.FreeThreadedDOMDocument.3.0")
xsl.async = false
Set template = Server.CreateObject("MSXML2.XSLTemplate")
'by using template we can dynamically send params to our xsl
template.stylesheet = xsl
set processor = template.createProcessor()
processor.input = xml
'HERE IS WHERE WE SEND PARAMETERS TO THE XSLT TO CONTINUE
'TO BE ABLE TO ACCESS THE PARAM'S IN THE XSL THE FORMAT IS LIKE THIS AT TOP-LEVEL <xsl:param name="arrivalDate"/>
'yourVar = Request.Form("yourVar")
'If yourVar <> "" Then
' processor.addParameter "yourVar", yourVar
'End If
processor.transform()
'Here is the final transformation to the browser, everything is sent downstream
Response.write (processor.output)
Set xsl = Nothing
Set xml = Nothing
Set xmlhttp = Nothing
Set template = Nothing
%>
Man, That code has helped me out! Thanks!
I have posted a question in a different thread about how to work with the response that UPS sends back. If you get a chance to take a look and see what you think I would be much grateful :)
Thanks,
Cody
<no sigs>
[edited by: Xoc at 7:33 pm (utc) on April 16, 2003]
[edit reason] removed sig [/edit]