It might help if I describe the full problem. I am trying to simulate this:
<form name="SearchForm" method="POST" id="SearchForm"
action="Search.ASP?WCI=getPage">
<input type="hidden" name="PAGE">
<input type="hidden" name="IsPortfolio">
<input type="hidden" name="DEL">
<input type="hidden" name="PropertyID">
<input type="hidden" name="GTYP" value="0">
<input type="hidden" name="PER" value="5">
<input type="hidden" name="RestrictSearch" value="">
<input type="hidden" Name="StyleSheet" value="">
<input type="hidden" name="STYPE" value="0">
<input type="hidden" name="Exit" value="">
<input type="hidden" name="GID" value="422">
<input type="hidden" name="CURRENCY" value="GBP">
So URL parameters AND form parameters going to the POSTed server. This is
currently triggered from the client side with a click to this:
javascript:document.SearchForm.PAGE.value='2';document.SearchForm.submit();
Doing the above works OK so all I want to do is simulate this. The object
being to bring back page 2 of N pages. A parameter is being passed to the
server by doing this. So I really need to simulate:
SearchForm.PAGE.value='2'. The server belongs to someone else so I can't
change anything at the POSTed end.
My Server Side code to simulate is as follows:
Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
strURL = "?WCI=getPage" & _
"&IsPortfolio" & _
"&DEL" & _
"&PropertyID" & _
">YP=0" & _
"&PAGE=2" & _
"&PER=5" & _
"&SearchForm.asp" & _
"&StyleSheet" & _
"&STYPE=0" & _
"&Exit" & _
"&GID=422" & _
"&CURRENCY=GBP"
xml.Open "POST","search.asp" & strURL, False
' ???????????????? Maybe this is the area
xml.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xml.Send "SearchForm"
' Create XML DOM object for the XML
Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
xmlDoc.async = False
xmlDoc.loadXML xml.responseText
' Create DOM object for the XSL
Set xslDoc = Server.CreateObject("Microsoft.XMLDOM")
xslDoc.async = False
' Load a stylesheet
xslDoc.load (Server.MapPath("Summary.XSLT"))
' Convert XML using XSL to HTML
strHTML = xmlDoc.transformNode(xslDoc)
' Send to client
Response.Write strHTML
' All finished
Set xml = Nothing
Set xslDoc = Nothing
Set xmlDoc = Nothing
Any help appreciated.
Barry.
<<<<<<<<<<<
If you are doing simulations then one tool that is indispensible is
www.fiddlertool.com
With this running use a browser to perform a Form post you want to emulate.
You can now check the recorded session in the tool an you'll see what you
need to reproduce.
If you noticed from the example Evertjan gave you when the form method is a
POST the set of field values should be sent as the entity body of the
request, IOW a string encoded as URL search section is passed as the
paremeter of the send function.
Hence your code should look more like:-
Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
strURL = "http//host.domain.com/search.asp?WCI=getPage"
strDat = "IsPortfolio=" & _
"&DEL=" & _
"&PropertyID=" & _
">YP=0" & _
"&PAGE=2" & _
"&PER=5" & _
"&RestrictSearch=" & _
"&StyleSheet=" & _
"&STYPE=0" & _
"&Exit=" & _
"&GID=422" & _
"&CURRENCY=GBP"
xml.Open "POST",strURL, False
xml.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xml.Send strDat
Note that any values that you might concatenate into the data needs to be
urlencoded,
BTW, are you sure the form post actually results in an XML response?