Hi,
I am posting data to a server using XML and using ASP POST method. The server then sends a response back in XML format. Can someone tell me how I can simply take the raw XML RESPONSE and print it to the screen and include all of the XML nodes? Here is the function and the rest of the code I am using:
Function PostXmlRequest(xmlDoc, verb)
'Create a new ServerXMLHTTP object to post the request and get
the response
set xmlRequest = Server.CreateObject("MSXML2.ServerXMLHTTP")
'** set method and server URL
xmlRequest.open "POST", ServerUrl
'** Set the required HTTP Headers for the request
xmlRequest.setRequestHeader "Content-Type", "text/xml"
'** Regulates versioning of the XML interface for the API
xmlRequest.setRequestHeader "X-API-COMPATIBILITY-LEVEL", "759"
xmlRequest.setRequestHeader "X-API-DEV-NAME", DevID
xmlRequest.setRequestHeader "X-API-APP-NAME", AppID
xmlRequest.setRequestHeader "X-API-CERT-NAME", CertID
xmlRequest.setRequestHeader "X-API-CALL-NAME", verb
xmlRequest.setRequestHeader "X-EBAY-API-SITEID", "0"
'** send the request
xmlRequest.send xmlDoc
If xmlRequest.status = 200 then
set PostXmlRequest = xmlRequest.responseXML
else
set PostXmlRequest = nothing
End If
End Function
'*** Load the XML Request template from file
set xmlRequestDoc = Server.CreateObject("MSXML2.DOMDocument")
xmlRequestDoc.load(Server.MapPath("request.xml"))
'*** SET VARIOUS XML NODE VALUES
'*** Set the different node values in the input file:
xmlRequestDoc.selectSingleNode("//GetProductsRequest/IncludeBuyingGuideDetails").text = "true"
xmlRequestDoc.selectSingleNode("//GetProductsRequest/IncludeHistogram").text = "true"
xmlRequestDoc.selectSingleNode("//GetProductsRequest/IncludeItemArray").text = "false"
xmlRequestDoc.selectSingleNode("//GetProductsRequest/IncludeReviewDetails").text = "true"
xmlRequestDoc.selectSingleNode("//GetProductsRequest/ProductSearch/QueryKeywords").text = thesearch
xmlRequestDoc.selectSingleNode("//GetProductsRequest/Pagination/EntriesPerPage").text = EntriesPerPage
xmlRequestDoc.selectSingleNode("//GetProductsRequest/Pagination/PageNumber").text = PageNumber
'*** Send the Request and Get Response (with Detail Level "0")
set xmlResponse = PostXmlRequest(xmlRequestDoc, "GetProducts")
'*** Check Response exists
if xmlResponse is nothing then
Response.Write("Request could not be completed")
else
'Get response into an Xml Document object
set xmlResponseDoc = Server.CreateObject("MSXML2.DOMDocument")
xmlResponseDoc.loadXml(xmlResponse.xml)
I am posting data to a server using XML and using ASP POST method. The server then sends a response back in XML format. Can someone tell me how I can simply take the raw XML RESPONSE and print it to the screen and include all of the XML nodes? Here is the function and the rest of the code I am using:
Function PostXmlRequest(xmlDoc, verb)
'Create a new ServerXMLHTTP object to post the request and get
the response
set xmlRequest = Server.CreateObject("MSXML2.ServerXMLHTTP")
'** set method and server URL
xmlRequest.open "POST", ServerUrl
'** Set the required HTTP Headers for the request
xmlRequest.setRequestHeader "Content-Type", "text/xml"
'** Regulates versioning of the XML interface for the API
xmlRequest.setRequestHeader "X-API-COMPATIBILITY-LEVEL", "759"
xmlRequest.setRequestHeader "X-API-DEV-NAME", DevID
xmlRequest.setRequestHeader "X-API-APP-NAME", AppID
xmlRequest.setRequestHeader "X-API-CERT-NAME", CertID
xmlRequest.setRequestHeader "X-API-CALL-NAME", verb
xmlRequest.setRequestHeader "X-EBAY-API-SITEID", "0"
'** send the request
xmlRequest.send xmlDoc
If xmlRequest.status = 200 then
set PostXmlRequest = xmlRequest.responseXML
else
set PostXmlRequest = nothing
End If
End Function
'*** Load the XML Request template from file
set xmlRequestDoc = Server.CreateObject("MSXML2.DOMDocument")
xmlRequestDoc.load(Server.MapPath("request.xml"))
'*** SET VARIOUS XML NODE VALUES
'*** Set the different node values in the input file:
xmlRequestDoc.selectSingleNode("//GetProductsRequest/IncludeBuyingGuideDetails").text = "true"
xmlRequestDoc.selectSingleNode("//GetProductsRequest/IncludeHistogram").text = "true"
xmlRequestDoc.selectSingleNode("//GetProductsRequest/IncludeItemArray").text = "false"
xmlRequestDoc.selectSingleNode("//GetProductsRequest/IncludeReviewDetails").text = "true"
xmlRequestDoc.selectSingleNode("//GetProductsRequest/ProductSearch/QueryKeywords").text = thesearch
xmlRequestDoc.selectSingleNode("//GetProductsRequest/Pagination/EntriesPerPage").text = EntriesPerPage
xmlRequestDoc.selectSingleNode("//GetProductsRequest/Pagination/PageNumber").text = PageNumber
'*** Send the Request and Get Response (with Detail Level "0")
set xmlResponse = PostXmlRequest(xmlRequestDoc, "GetProducts")
'*** Check Response exists
if xmlResponse is nothing then
Response.Write("Request could not be completed")
else
'Get response into an Xml Document object
set xmlResponseDoc = Server.CreateObject("MSXML2.DOMDocument")
xmlResponseDoc.loadXml(xmlResponse.xml)