473,408 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Problem posting xml string using Msxml2.ServerXMLHTTP in classic ASP

I am attempting to send a purchase request string to a webservice on a remote site I am able to successfully send the quoterequest using Msxml2.ServerXMLHTTP on one page and parse the response. When I try to send the purchaserequest on the next page to the same URL, I get an "Unable to Parse" error and the POST never leaves my server. Please help!

Working POST (quoterequest)
Expand|Select|Wrap|Line Numbers
  1. <%@ LANGUAGE="VBSCRIPT"%>
  2. <!-- #include virtual="/COMMON/global.inc" -->
  3. <%
  4. '********************************************
  5. ' BUILD XML AND SEND TO CSA
  6. '********************************************
  7. TOTAL_PREMIUM = 0
  8. ERROR = 0
  9. ERROR_MESSAGE = ""
  10.  
  11. 'strXml = "<?xml version=&apos;1.0&apos;?>"
  12. strXml = "<?xml version='1.0'?> "
  13. strXml = strXml & "<quoterequest>"
  14. strXml = strXml & "<aff>83079568</aff>"
  15. strXml = strXml & "<producer>83079568</producer>"
  16. strXml = strXml & "<productclass>FREESTYLELUXE</productclass>"
  17. strXml = strXml & "<bookingreservno></bookingreservno>"
  18. strXml = strXml & "<numinsured>" & session("NUMBER_OF_TRAVELERS") & "</numinsured>"
  19. strXml = strXml & "<tripcost>" + session("TOTAL_TRIP_COST") + "</tripcost>"
  20. strXml = strXml & "<departdate>" & strDepartureDate & "</departdate>"
  21. strXml = strXml & "<returndate>" & strReturnDate & "</returndate>"
  22. strXml = strXml & "<initdate>" & strInitPaymentDate & "</initdate>"
  23. strXml = strXml & "<finalpaymentdate>" & strFinalPaymentDate & "</finalpaymentdate>"
  24. strXml = strXml & "<travelers>"
  25.  
  26. For n = 1 to session("NUMBER_OF_TRAVELERS")
  27.     strXml = strXml & "<traveler>"
  28.     strXml = strXml & "<age>" & getAge(session("TRAV"&n&"_DOB")) & "</age>"
  29.     strXml = strXml & "</traveler>"
  30. Next
  31.  
  32. strXml = strXml & "</travelers>"
  33. strXml = strXml & "</quoterequest>"
  34.  
  35. strXml = "&xmlrequeststring=" & Server.URLEncode(strXml)
  36.  
  37. set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
  38. objHttp.open "POST","https://www.csatravelprotection.com/jsp/getrequest.jsp", false
  39. objHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
  40. objHttp.send strXml
  41.  
  42. strStatus = objHTTP.status
  43. strStatusText = objHTTP.statusText
  44. strResponseText = objHTTP.responseText
  45.  
  46. '********************************************
  47. ' Error Variables
  48. '********************************************
  49. session("strRequestString") = strXml
  50. session("strResponseXml") = strResponseText
  51.  
  52. '********************************************
  53. ' TRANSLATE RESPONSE INTO XML DOC
  54. '********************************************
  55. set xmlResponseDoc = CreateObject("MSXML2.DOMDocument")
  56. xmlResponseDoc.setProperty "ServerHTTPRequest", True
  57. xmlResponseDoc.async = False
  58. xmlResponseDoc.LoadXML strResponseText
  59.  
  60. strResponseXml = xmlResponseDoc.xml
  61. strResponseXml = Replace(strResponseXml, "<", "&lt;")
  62. strResponseXml = Replace(strResponseXml, ">", "&gt;")
  63. strResponseXml = Replace(strResponseXml, chr(10), "<BR>")
  64.  
  65. xmlResponseDocStatus = ""
  66.  
  67. '********************************************
  68. ' PARSE QUOTE FROM RESPONSE XML
  69. '********************************************
  70. if (strStatus = 200) then
  71.  
  72.     TOTAL_PREMIUM = xmlResponseDoc.selectSingleNode("/quoteresponse/price").text
  73.  
  74.     SET oErrorNode = xmlResponseDoc.selectSingleNode("//errormessage")
  75.     if Not oErrorNode Is Nothing then
  76.         ERROR_MESSAGE = oErrorNode.text
  77.     end if
  78.  
  79. else
  80.  
  81.     ERROR = 1
  82.     ERROR_MESSAGE = "Error Connecting to CSA"
  83.     response.Redirect("csa_error.asp?PRODUCT=CSA-LUXE&SITE=" & GLOBAL_SITE_ABBR & "&ERROR_TEXT=" & server.urlencode(ERROR_MESSAGE))
  84.  
  85. end if
  86.  
  87. '********************************************
  88. ' SERVER ERROR CHECKING
  89. '********************************************
  90. if err.Number <> 0 Then
  91.  
  92.     ERROR = 1
  93.  
  94.     if (err.Description <> "Object required" AND err.Description <> "Unspecified error") then
  95.         ERROR_MESSAGE = err.Description & " (" & err.Number & ")"
  96.     else
  97.         ERROR_MESSAGE = "CSA's Travel Insurance System is not responding.  Please try again later..."
  98.     end if
  99.  
  100.     err.Clear
  101.  
  102.     response.Redirect("csa_error.asp?PRODUCT=CSA-LUXE&SITE=" & GLOBAL_SITE_ABBR & "&ERROR_TEXT=" & server.urlencode(ERROR_MESSAGE))
  103.  
  104. end if
  105.  
  106. Set objhttp = nothing
  107.  
"Broken" POST (purchaserequest)
Expand|Select|Wrap|Line Numbers
  1. <%@ LANGUAGE="VBSCRIPT"%>
  2. <!-- #include virtual="/COMMON/global.inc" -->
  3. <%
  4. ********************************************
  5. ' BUILD XML AND SEND TO CSA
  6. '********************************************
  7.  
  8. ERROR_TEXT = ""
  9. STATUS_CODE = 0
  10.  
  11. strXml = "<?xml version='1.0'?> "
  12. strXml = strXml & "<purchaserequest>"
  13. strXml = strXml & "<actioncode>NEW</actioncode>"
  14. strXml = strXml & "<aff>83079568</aff>"
  15. strXml = strXml & "<producer>83079568</producer>"
  16. strXml = strXml & "<productclass>FREESTYLELUXE</productclass>"
  17. strXml = strXml & "<bookingreservno></bookingreservno>"
  18. strXml = strXml & "<airflightflag>0</airflightflag>"
  19. strXml = strXml & "<printpolconfltr>3</printpolconfltr>"
  20. strXml = strXml & "<emailaddress>policies@utravelpro.com</emailaddress>"
  21. strXml = strXml & "<agentid></agentid>"
  22. strXml = strXml & "<agentemail>sales@utravelpro.com</agentemail>"
  23. strXml = strXml & "<numinsured>1</numinsured>"
  24. strXml = strXml & "<tripcost>1000</tripcost>"
  25. strXml = strXml & "<departdate>2010-10-28</departdate>"
  26. strXml = strXml & "<returndate>2010-10-29</returndate>"
  27. strXml = strXml & "<initdate>2010-05-05</initdate>"
  28. strXml = strXml & "<finalpaymentdate>2010-05-07</finalpaymentdate>"
  29. strXml = strXml & "<travelers>"
  30.     strXml = strXml & "<traveler>"
  31.     strXml = strXml & "<travelerfirstname>Alex</travelerfirstname>"
  32.     strXml = strXml & "<travelerlastname>Gonser</travelerlastname>"
  33.     strXml = strXml & "<age>33</age>"
  34.     strXml = strXml & "</traveler>"
  35. strXml = strXml & "</travelers>"
  36. strXml = strXml & "<address1>5530 Melshire Dr</address1>"
  37. strXml = strXml & "<address2></address2>"
  38. strXml = strXml & "<city>Dallas</city>"
  39. strXml = strXml & "<state>TX</state>"
  40. strXml = strXml & "<zipcode>75230</zipcode>"
  41. strXml = strXml & "<country>United States</country>"
  42. strXml = strXml & "<telephonehome>9999999999</telephonehome>"
  43. strXml = strXml & "<destination>Australia</destination>"
  44. strXml = strXml & "<supplier>Diller & Fisher</supplier>"
  45. strXml = strXml & "<airline>American</airline>"
  46. strXml = strXml & "<bebficiaryfirstname>Trudi</beneficiaryfirstname>"
  47. strXml = strXml & "<bebficiarylastname>Gonser</beneficiarylastname>"
  48. strXml = strXml & "<beneficiaryrelationship>Mother</beneficiaryrelationship>"
  49. strXml = strXml & "<price>86</price>"
  50. strXml = strXml & "<paymentmethod>Vi</paymentmethod>"
  51. strXml = strXml & "<ccorcheckno>4111111111111111</ccorcheckno>"
  52. strXml = strXml & "<ccexpiration>1210</ccexpiration>"
  53. strXml = strXml & "<ccname>Alex Gonser</ccname>"
  54. strXml = strXml & "<cczipcode>75230</cczipcode>"
  55. strXml = strXml & "</purchaserequest>"
  56.  
  57. strXml = "&xmlrequeststring=" & Server.URLEncode(strXml)
  58.  
  59. '********************************************
  60. ' SEND XML HTTP POST
  61. '********************************************
  62.  
  63. set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
  64. objHTTP.Open "POST", "https://www.csatravelprotection.com/jsp/getrequest.jsp", False
  65. objHTTP.ContentLength = strXml.Length
  66. objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
  67. objHTTP.send strXml
  68.  
  69. strStatus = objHTTP.status
  70. strStatusText = objHTTP.statusText
  71. strResponseText = objHTTP.responseText
  72.  
  73. '********************************************
  74. ' Error Variables
  75. '********************************************
  76. session("strRequestString") = strXml
  77. session("strResponseXml") = strResponseText
  78.  
  79. '********************************************
  80. ' TRANSLATE RESPONSE INTO XML DOC
  81. '********************************************
  82. Set xmlResponseDoc = CreateObject("MSXML2.DOMDocument")
  83. xmlResponseDoc.setProperty "ServerHTTPRequest", True
  84. xmlResponseDoc.async = False
  85. xmlResponseDoc.LoadXML strResponseText
  86.  
  87. strResponseXml = xmlResponseDoc.xml
  88. strResponseXml = Replace(strResponseXml, "<", "&lt;")
  89. strResponseXml = Replace(strResponseXml, ">", "&gt;")
  90. strResponseXml = Replace(strResponseXml, chr(10), "<BR>")
  91.  
  92. xmlResponseDocStatus = ""
  93.  
  94. '********************************************
  95. ' PARSE QUOTE FROM RESPONSE XML
  96. '********************************************
  97. if (strStatus = 200) then
  98.  
  99.     STATUS_CODE = xmlResponseDoc.selectSingleNode("//intStatusCode").text
  100.     POLICY_NUMBER = xmlResponseDoc.selectSingleNode("//strPolicyNumber").text
  101.     ORDER_NUMBER = xmlResponseDoc.selectSingleNode("//strConfirmationNumber").text
  102.     ERROR_MESSAGE = xmlResponseDoc.selectSingleNode("//strStatusMessage").text
  103.     MESSAGE = xmlResponseDoc.selectSingleNode("//strMessage").text
  104.     MISSING_INPUT = xmlResponseDoc.selectSingleNode("//strMissingInput").text
  105.     ERROR_KEY = xmlResponseDoc.selectSingleNode("//strErrorKey").text
  106.     ERROR_ID = xmlResponseDoc.selectSingleNode("//strErrorID").text
  107.     TOTAL_BILLED = xmlResponseDoc.selectSingleNode("//dblAmountBilled").text
  108.  
  109. else
  110.  
  111.     STATUS_CODE = "-1"
  112.     ERROR_MESSAGE = "Error Connecting to our Partner System"
  113.  
  114. end if
  115.  
  116. set objHttp = nothing
  117. set xmlResponseDoc = nothing
  118.  
Thanx again for any help.
Aug 4 '10 #1
0 2226

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: ehilario | last post by:
Thanks Mark, That 's better than internal server error. This is what came back, which is confusing because when its called locally it comes back fine. Am I missing something? -Ed
5
by: katrinaVictim | last post by:
Question: I get the eror listed at the bottom of the post. What can I do to make the response of the x1.send a "binary" type? Or, in general, how can I just "make this work"? <%@...
2
by: Michael Christensen | last post by:
Hi How do I send an input-param to my web service with MSXML2.ServerXMLHTTP? Can this be done without the soap-toolkit? Can't find anything about it - looking forward getting some help :-)...
0
by: Sia Jai Sung | last post by:
Hi, I need to write a ASPX file that will post some request to other party (web service written in java), here is my code, <%@ Page aspcompat=true %> <% Dim xml, url
1
by: Raúl Martín | last post by:
I´ve a function in asp that run correctly but If I tried to change it forasp.net in asp: xmlHTTP = CreateObject("Microsoft.XMLHTTP") And I thought to use this sentence for asp.net but the...
2
by: Maris Janis Vasilevskis | last post by:
Hi, Is it possible to force HttpWebRequest to do exactly (not approximately) the same as MSXML2.ServerXMLHTTP does? More details. I port JScript to JScript.NET I have a server (ASP invoking...
0
by: Dick Berthold | last post by:
Is there a way to force all data to be sent in a single transmission using MSXML2.ServerXMLHTTP.send? I am sending XML data to a site which is experiencing problems if the there are more than 8192...
8
by: lopi | last post by:
Hello. I'm trying to remotely get a pdf file - http://remoteServer/file.pdf - in order to store it into another server, maybe with Scripting.FileSystemObject However the following code doesn't...
1
by: niklang | last post by:
Hi everybody, I have an ASP page that uses the MSXML2.ServerXMLHTTP object to read a stylesheet from IIS as follows: strXSLPath = "http://localhost/ej/ejdetail.xsl.asp" ...
3
by: dfordinal | last post by:
I am calling a remote web server and awaiting data that is being passed back to my process in a form variable. postData = "fname=John" Set xmlHttp =...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.