Log in

View Full Version : asp form post and xml response



neontwenty
10-04-2010, 07:07 PM
hi friends
im doing an xm hotel reservation b2c projects where im supposed to
send xml request to the main server and get response in return.
here is a the sample request

<form action="http://www.servername.com/xml_req_parser.php" method="post">
<textarea name="xml" cols="90" rows="20">
<?xml version="1.0" encoding="UTF-8" ?>
<XMLRequest>
<RequestType>DestinationListRequest</RequestType>
<RequestLogin>
<AffiliateCode>AF0001</AffiliateCode>
<AffiliateUsername>myUserName</AffiliateUsername>
<AffiliatePassword>myPassword</AffiliatePassword>
<AffRequestId>5</AffRequestId>
<AffRequestTime><%=now()%></AffRequestTime>
</RequestLogin>
<DestinationListInfo>
<CompleteList>false</CompleteList>
</DestinationListInfo>
</XMLRequest>
</textarea><br>
<input type="submit">
</form>

in return i get the response from http://www.servername.com/xml_req_parser.php
which is the form target.

<?xml version="1.0" encoding="UTF-8" ?>
<XMLResponse>
<ResponseType>HotelListResponse</ResponseType>
<RequestInfo>
<AffiliateCode>AF001</AffiliateCode>
<AffRequestId>5</AffRequestId>
<AffRequestTime>2010-09-30T14:43:24</AffRequestTime>
</RequestInfo>
<TotalNumber>51397</TotalNumber>
<Hotels>
<Hotel>
<HotelCode>ABCDE</HotelCode>
<DestinationId>NFUE</DestinationId>
<Destination>Nice</Destination>
<Country>France</Country>
<HotelName>One Spa Hotel</HotelName>
<StarRating>4</StarRating>
</Hotel>
<Hotel>
<--record 2 here-->
</Hotel>
<Hotel>
<--record 51397 here-->
</Hotel>
</Hotels>
</XMLResponse>

as the response is only after submiting a form how can i load the xml
into my asp program so that i can display the result in web page.
kindly help

neon

neontwenty
10-05-2010, 08:06 AM
i used ServerXMLHTTP that failed to load the xml, showing

XML load failed: XML document must have a top level element.

the xml actually having top level element in the response xml that i could see. i assume
it is not get loaded here.

below is the code i wrote


<%
req=request.Form("xml") '// i changed the form ACTION to this page

Set httpObj = Server.CreateObject("msxml2.ServerXMLHTTP")
httpObj.Open "POST", "serverurl/xml_req_parser.php", False
httpObj.Send req



Set xmlObj = Server.CreateObject("Microsoft.XMLDOM")
'//xmlObj.Load httpObj.ResponseXML
xmlObj.Load httpObj.ResponseXML.xml


if xmlObj.parseError.reason <> "" then
Response.Write "XML load failed: " & xmlObj.parseError.reason & "<br>"
response.end
else
response.Write "load success"
end if

set rootObj=xmlObj.getElementsByTagName("Rooms")

response.Write rootObj.length
%>