Click here to Skip to main content
15,904,024 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello

i have a problem with classic asp page requests an asp.net web service

no exception triggered but no result appeared

I'm calling a method from the service "Process"

accepts string parameter called path

and returns nothing
my asp page code is:
<html>
<head>
<title>Calling a webservice from classic ASP</title>
</head>
<body>
<%
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
  Dim xmlhttp
  Dim DataToSend
  DataToSend="path="&Request.Form("text1")
  Dim postUrl
  postUrl = "http://..Server../service.asmx/Process"
  Set xmlhttp = server.Createobject("MSXML2.XMLHTTP")
  xmlhttp.Open "POST",postUrl,false
  xmlhttp.setRequestHeader "Content-Type", _
      "application/x-www-form-urlencoded"
  xmlhttp.send DataToSend
  Response.Write(xmlhttp.responseText)
End If
%>
<FORM method=POST name="form1">
Enter Values to be Added<br>
<INPUT type="text" value="String value to be send" name="text1">
<br><br>
<INPUT type="submit" value="Add" name="submit1">
</form>
</body>
</html>
</br></br></br>


also i tried the code with an asp.net page

<br />
MyService ss = new MyService();<br />
ss.Process(TextBox1.Text);<br />


and that worked correctly

please someone help what's wrong with it ?
Posted
Updated 22-Dec-10 19:20pm
v2

1 solution

VB
xmlhttp.send DataToSend
Response.Write(xmlhttp.responseText)


I'm not an expert in old-school ASP, but that looks suspect to me. I would expect the call to be asynchronous, so you are attempting to write out the response before you've received it. A better bet would be to use jQuery to call the site for you. I have an article here[^] that demonstrates how to do this in jQuery.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900